I have defined the adaptor of the DataManager as JsonAdaptor in my markup and assigned the datasource in my code behind. I then want to retrieve that datasource from the DataManager in javascript.
How do I reference the DataManager in javascript and retrieve the datasource?
Sample code below:
Markup
<ej:DataManager ID="dmSuppliers" runat="server" Text="DataManager" Adaptor="JsonAdaptor" />
.CS
private void BindSupplierDataManager()
{
var suppliers = new List<IdStringPair>()
{
new IdStringPair(1, "Magenta"),
new IdStringPair(2, "Trans"),
new IdStringPair(3, "SuperSupplier")
};
dmSuppliers.Json = suppliers;
}
JS
function writeSupplierName(args) {
var dropData = [
//Retrieve datasource from datamanager
];
var selIndex = [];
if (args.rowdata != undefined) {
for (j = 0; j < dropData.length; j++) {
if (args.rowdata["SupplierName"] == dropData[j]) {
selIndex.push(j);
break;
}
}
}
args.element.ejDropDownList({
width: "100%",
dataSource: dropData,
fields: { id: "text", text: "text", value: "value" },
selectedItems: args.rowdata !== undefined ? selIndex : ""
});
}