Hello
I have a series of Dropdownlists in a mask that all work fine so far. They all have a select event for some background tasks. For programmatically rebuilding these Dropdownlists (in case the user wants to make some changes later on) I rebuild/display first all the Dropdownlists, fill them up by the attached datasources and then set the pre-set value (previously done by user) by triggering the specific select event on the specific Dropdownlist (cascading). But triggering the select event programmatically I got an error:
TypeError: undefined is not an object (evaluating 'e.item.index')
This error is caused inside the select event (on Dropdownlist) by this line:
var objectTargetId = this.dataItem(e.item.index()).objectTargetId;
After some investigations I found out that it would be easier to me to switch to change event inside Dropdownlist. The error causing line causes also the same error in change event, so I replaced the line by:
var objectTargetId = this.value();
Works fine so far.
One of the Dropdownlist has an additional custom field:
$("#objecttarget"+conditionNumber).kendoDropDownList({
dataValueField: "objectTargetId",
dataTextField: "objectTargetText",
dataTypeField: "objectTargetType",
change: function(e) { ...
I wonder now how I can access the value of "dataTypeField" inside the change event of this Dropdownlist? Previously (select event) it worked that way:
this.dataItem(e.item.index()).objectTargetType;
My current solution looks like this:
var selIndex = $("#objecttarget"+conditionNumber).data("kendoDropDownList").selectedIndex;
var objectTargetType = $("#objecttarget"+conditionNumber).data("kendoDropDownList").options.dataSource._view[selIndex].objectTargetType;
That seems to work too but I don't feel well going through the specific structure, that might change in future. Is there an easier, more official way to get the value of a custom field (in my case "objectTargetType"?
Regards