|
<div>
<ejs-dropdownlist id="customers" query="new ej.data.Query().from('Customers').select(['ContactName', 'CustomerID']).take(6)"placeholder="Select a customer" popupHeight="200px">
<e-dropdownlist-fields text="ContactName" value="CustomerID"></e-dropdownlist-fields>
<e-datamanager url="http://services.odata.org/V4/Northwind/Northwind.svc/" adaptor="ODataV4Adaptor" crossDomain="true"></e-datamanager>
</ejs-dropdownlist>
<button id="reload" onclick="onReload()">Reload</button>
</div>
<script>
function onReload() {
var instance = document.getElementById("customers").ej2_instances[0];
instance.index = 0;
}
</script> |
|
<script type="text/javascript">
window.onload = function () {
console.log('window - onload');
var dropObject = document.getElementById("customers");
var dropDownListObject = dropObject.ej2_instances[0];
dropDownListObject.index = 0; // set index on initially
};
function onComplete(args) {
var dropObject = document.getElementById("customers");
var dropDownListObject = dropObject.ej2_instances[0];
dropDownListObject.index = 0; // set index on every changing the datasource
} |
|
document.getElementById("btn").onclick = () => {
var dropObject = document.getElementById("customers");
var dropDownListObject = dropObject.ej2_instances[0];
dropDownListObject.dataSource = new ej.data.DataManager({
}); // changing datasource
dropDownListObject.query = new ej.data.Query().from('Customers').select(['ContactName','CustomerID']).skip(6).take(10);; // changing query
}; |
|
<script type="text/javascript">
window.onload = function () {
console.log('window - onload');
var dropObject = document.getElementById("customers");
var dropDownListObject = dropObject.ej2_instances[0];
dropDownListObject.index = 0;
};
function onComplete(args) {
var dropObject = document.getElementById("customers");
var dropDownListObject = dropObject.ej2_instances[0];
dropDownListObject.index = 0;
if (!ejs.base.isNullOrUndefined(dropDownListObject.listData)) {
dropDownListObject.itemData = args.result[dropDownListObject.index];
var event = new Event("change");
dropDownListObject.onChangeEvent(event);
}
}
function onchange(args) {
console.log("Change triggered");
}
document.getElementById("btn").onclick = () => {
var dropObject = document.getElementById("customers");
var dropDownListObject = dropObject.ej2_instances[0];
dropDownListObject.dataSource = new ej.data.DataManager({
url: "http://services.odata.org/V4/Northwind/Northwind.svc/", adaptor: new ej.data.ODataV4Adaptor
});
dropDownListObject.query = new ej.data.Query().from('Customers').select(['ContactName', 'CustomerID']).skip(6).take(10);
dropDownListObject.value = null;
dropDownListObject.text = null;
dropDownListObject.index = 0;
dropDownListObject.refresh();
};
</script> |
|
function onComplete(args) {
var dropObject = document.getElementById("customers");
var dropDownListObject = dropObject.ej2_instances[0];
dropDownListObject.index = 0;
if (!ejs.base.isNullOrUndefined(dropDownListObject.listData)) {
dropDownListObject.itemData = args.result[dropDownListObject.index];
var event = new Event("change");
dropDownListObject.onChangeEvent(event);
}
}
|