I have some oData coming back from the lastest ASP.NET web api that looks like this:
{ "odata.metadata":"http://mydomain/odata/$metadata#Users", "odata.count":"3", "value":[ {"FirstName":"Alan","MiddleName":"A.","LastName":"Arlington"}, {"FirstName":"Brad","MiddleName":"B.","LastName":"Boston"}, {"FirstName":"Dirk","MiddleName":"J.","LastName":"Watkins"} ] }
How can I bind this to the igCombo? Notice that the total record count has a dot in the property name. Also, how do I get the igCombo to stop looking for a root of "d"?
I've tried tons of stuff, including the below. Any ideas?
var usersDS = new $.ig.RemoteDataSource({ dataSource: '/odata/Users?', type: 'json', responseDataType: 'json', responseTotalRecCountKey: 'odata.count', responseDataKey: 'value', }); $('#combo').igCombo({ loadOnDemandSettings: { enabled: true, pageSize: 10 }, mode: 'readonlylist', dataSource: usersDS, filteringType: 'remote', width: '250px', textKey: 'LastName', valueKey: 'FirstName', virtualization: true, autoComplete: true, itemTemplate: '${FirstName} ${LastName}', nullText: 'Select an employee' });
hi,
I am just checking if the latest reply helped you out or you require any further assistance on the matter.
No, it does not work as the json data returned has "odata.count":"30" for ResponseTotalRecCountKey. The Combo can display data if I use .ResponseTotalRecCountKey("30") instead in the option.
Hello lojofa,
The actual setup depends on the generated JSON response from the Service used.
For example if response contains both results and record count (notice that not all services support this - inlinecount) and contains results and count in specific format you have to match this format in settings too. For example:
responseDataKey: "d.results.Results",
responseTotalRecCountKey: "d.results.Count",
More information about oData services you can read here - http://www.odata.org/documentation/odata-v2-documentation/uri-conventions/
Hope this helps.
Then do something like this:
var availableMattersUrl = "/odata/Clients('" + clientId + "')/Matters"; var ds = new $.ig.JSONPDataSource({ dataSource: availableMattersUrl, responseDataKey: "value", responseTotalRecCountKey: "odata.count" }); $('#AvailableMattersGrid').igGrid({ dataSource: ds, responseDataKey: "value", responseTotalRecCountKey: "odata.count", primaryKey: 'Id', localSchemaTransform: false, autoGenerateColumns: false, fixedHeaders: false, autoAdjustHeight: false, width: '100%', enableHoverStyles: false, columns: [ { key: 'Id', headerText: 'Id', dataType: 'string', formatter: formatString }, { key: 'Name', headerText: 'Matter', dataType: 'string', formatter: formatString, template: '${Name}' }, { key: 'OpenedDate', headerText: 'Opened', dataType: 'date', formatter: formatDate}, ], features: [ { name: "Sorting", type: "remote", columnSettings: [ { columnKey: 'OpenedDate', firstSortDirection: "descending" } ], columnSorted: function (evt, ui) { //page it back to 0 ui.owner.element.igGridPaging("pageIndex", 0); } }, { name: "Paging", type: "remote", pageSize: 5 }, { name: "Filtering", type: "remote", allowFiltering: true, caseSensitive: false, filterSummaryTemplate: '${matches} matches' } ], rendered: function (evt, ui) { //fix the igGrid padding found in IE8. $('.ui-iggrid-scrolldiv').css('padding', '0').css('width', '100%'); //$('#NewBudgetsGrid tr :nth-child(4)').addClass('numCol'); //$('#NewBudgetsGrid tr :nth-child(5)').addClass('numCol'); } });
My guess is that the problem comes down to the period in the field name "odata.count". I see in infragistics.datasource.js (around line 1936) there is a call that splits the responseTotalRecCountKey by the period.
totalRecPath = key.split("."); rec = dsObj; for (i = 0; i < totalRecPath.length; i++) { rec = rec[totalRecPath[i]] }
I think this makes it impossible to use the default webAPI oData response for inlineCount. What do you think the work around would be?
Using version 13.1.20131.1012