My Code
Need to By default set item to "ALL"
placeholder="Select" popupHeight="220px" allowFiltering="true" focus="addNullDesignation">
Need to By default Show item to "ALL"
My Code
Need to By default set item to "ALL"
placeholder="Select" popupHeight="220px" allowFiltering="true" focus="addNullDesignation">
Need to By default Show item to "ALL"
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sachin SinghPosted Jan 18, 2024, 10:09 AM
Then check with the index property
Mithun PradhanPosted Jan 18, 2024, 10:02 AM
Set dropObject.value = 0; Not working
var focusNullDesignation = false;
function addNullDesignation() {
if (!focusNullDesignation) {
var dropObject = document.getElementById("drpDesignationGroup")["ej2_instances"][0];
// Add "ALL" item at the first position
dropObject.addItem({ Value: 0, Text: "ALL" }, 0);
// Add "Null Designations" item at the second position
dropObject.addItem({ Value: -1, Text: "Null Designations" }, 1);
// Set "ALL" as the default selected item using the value property
dropObject.value = 0;
// Update the dropdown list
dropObject.dataBind();
}
focusNullDesignation = true;
}
screenshot my output
Actual Need to
Sachin SinghPosted Jan 18, 2024, 9:36 AM
you just need to assign the value of the option you want as selected, as in your case you want "ALL" so do this
Naimish MakwanaPosted Jan 18, 2024, 9:21 AM
To set the default selected item to “ALL”, you can add a line of code to select the “ALL” item after adding it. Here’s how you can modify your
addNullDesignationfunction:This will set the default selected item to “ALL” when the dropdown list is focused. The
dropObject.value = 0;line sets the selected item to the one with a value of 0, which is “ALL”.