I am using a datasource in my .igCombo() which returns json data comprising of several {"id":"name"} items . They have no header or key information like 0:{"Key":"id","Value":"name"} , so that I don't have any pre demarcated valueKey option.
I am trying to declare a json schema like
var jsonSchema = new $.ig.DataSchema("json", {fields:[ {name: "zoneId", type: "string"}, {name: "siteName", type: "string"}] });
But , as soon as I bind this
var ds = new $.ig.DataSource({ type: "json", dataSource: url, schema: jsonSchema });
It hits my datasource and without any skip or top values and no data is being returned from there.
How to work in such cases , or do I need to modify the json response to always include predefined valueKey options in the response.
Hello Debashish,
Thank you for posting in our forum.
I assume by valueKey you mean responseDataKey option of the grid. It is not required in this case. I tested your scenario and it works correctly. You only have to call ds.dataBind() after defining the data source. Then you can get the actual data: ds.data().
Let me know if this helps.
Hi Nikolay,
My problem still persists.
I will give my implementation here :
var ds = new $.ig.DataSource({ type: "json", dataSource: url, schema: jsonSchema }).dataBind();
$("#campaign_options").igCombo({ autoComplete : true, autoSuggestion: true, filteringType : 'remote', dataSource : ds.data(), responseDataKey : "response.data", //which key in the JSON response we should look for the drop down data. responseTotalRecCountKey : "response.totalRecordsInServer", //which key we should look for the total record in server side. loadOnDemandSettings : { enabled : true, pageSize : 20 }, dataSourceUrl: url, width: "250px", filterExprUrlKey: 'startsWith', virtualization: true, valueKey : "zoneId", textKey : "siteName", headerTemplate : '<div id="comboHeaderTemplate" class="comboTemplates">Filtered Names</div>', itemTemplate: '<div class="comboItemContainer"><div class="empImage"> <img src="/img/lilimg.gif" width="64px" height="64px" alt="${zoneId}"/> </div> <div class="empInfo"><span class"=empName">${siteName}</span></div></div>', footerTemplate : '<div id="comboFooterTemplate" class="comboTemplates" class="boxed"> {0} of {3}</div>', nullText : 'No Result',
});
Now , backend server logic is such that , on every call it will read the $top and $skip parameters and slice the data starting from $skip value and including $top number of rows.
In this case as soon as .databind() event is fired , an ajax call http://localhost:9004/myproj/getdropdownlist?_=1394020227989 is fired without the $top or $skip parameters and hence no data is being returned.
I am not sure where I am doing wron . Is it not the correct away I am implementing my logic.
For your reference , I am also attaching a sample sub set of the json data that I am generating in the backend.
{"response":{"data":{"-1":"All Campaigns","25_g":"HelloTests","43_g":"jk camp test","45_g":"Mm CampGroup 0430","9_g":"new - i test - new","44_g":"New Group 0408","2325":"AA-MM_EyP","2395":"AA-MM_EyP -New 06\/10\/10","2729":"AA-MM_EyP -New 06\/10\/10 -New 08\/17\/12","2412":"AA-MM_EyP -New 06\/14\/10","2586":"Ad Network Test new","2583":"add west test","2328":"ADEXCHANGER CPC 10","2567":"ADEXCHANGER CPC 5","2497":"aditic test campaign","2581":"aditic test campaign -New 11\/01\/11"},"totalRecordsInServer":16}}
{"response":{"data":{"-1":"All Campaigns","25_g":"HelloTests","43_g":"jk camp test","45_g":"Mm CampGroup
0430","9_g":"new - i test - new","44_g":"New Group 0408","2325":"AA-MM_EyP","2395":"AA-MM_EyP -New 06
\/10\/10","2729":"AA-MM_EyP -New 06\/10\/10 -New 08\/17\/12","2412":"AA-MM_EyP -New 06\/14\/10","2586"
:"Ad Network Test new","2583":"add west test","2328":"ADEXCHANGER CPC 10","2567":"ADEXCHANGER CPC 5"
,"2497":"aditic test campaign","2581":"aditic test campaign -New 11\/01\/11"}
Hello,
I don't see "zoneId" or "siteName" properties in your json data and you are using them in the dataSchema. This may be the reason why no items are displayed in the combo. The fields in the igDataSchema should match these in the actual data source. Here you can find more information on the matter: http://help.infragistics.com/Doc/jQuery/2013.2/CLR4.0?page=igDataSource_Using_DataSchema.html
Let me know if you have any further questions.
Hi,
I'm just checking if you need any further assistance with the matter.
It is possible to attach an example