Hi,
We have created a custom grid using ejGrid component and used 'editType='dropdownedit' in e-columns component in order to get the dropdowns while editing a row in grid. In our example we have 3 dropdowns in which on selecting the value from first dropdown, the second should populate its corresponding data and similarly on selecting the value from second dropdown, third dropdown should get loaded with data dynamically. When we added a function consisting of getting the data based on selectin and binding the dropdown inside on change of first drop down, the bind function is not working properly. Even if we get the correct data , it is not being bounded properly.
Here is our code:
html:
component.ts
|
[app.component.ts]
this.countryParams = {
---
write: (args) => {
this.countryObj = new DropDownList({
dataSource: this.country,
fields: { value: 'countryId', text: 'countryName' },
change: () => {
// change the query of state dropdown
this.stateObj.enabled = true;
let tempQuery: Query = new Query().where(
'countryId',
'equal',
this.countryObj.value
);
this.stateObj.query = tempQuery;
this.stateObj.text = null;
this.stateObj.dataBind();
},
placeholder: 'Select a country',
floatLabelType: 'Never',
});
this.countryObj.appendTo(args.element);
},
};
this.stateParams = {
---
write: (args) => {
this.stateObj = new DropDownList({
dataSource: this.state,
fields: { value: 'stateId', text: 'stateName' },
enabled: false,
placeholder: 'Select a state',
floatLabelType: 'Never',
change: () => {
// change the query of city dropdown
this.cityObj.enabled = true;
let tempQuery: Query = new Query().where(
'stateId',
'equal',
this.stateObj.value
);
this.cityObj.query = tempQuery;
this.cityObj.text = null;
this.cityObj.dataBind();
},
});
this.stateObj.appendTo(args.element);
},
};
this.cityParams = {
---
write: (args) => {
this.cityObj = new DropDownList({
dataSource: this.city,
fields: { value: 'cityId', text: 'cityName' },
enabled: false,
placeholder: 'Select a city',
floatLabelType: 'Never',
});
this.cityObj.appendTo(args.element);
},
};
|