Hi, I’m trying to bind a knockout view to a readonly datasource like defined like so
<table id="grid" data-bind="
igGrid: {
dataSource: igDataSource,
width: 1100,
height: 500,
primaryKey: 'CustomerID',
autoCommit: false,
features: [{
name: 'Updating', editMode: 'row',
}
],
autoGenerateColumns: false,
columns: [
{ key: 'CustomerID', headerText: 'Customer ID', width: 80, dataType: 'string' },
{ key: 'Country', headerText: 'Country', width: 150, dataType: 'string' },
{ key: 'City', headerText: 'City', width: 100, dataType: 'string' },
{ key: 'ContactName', headerText: 'Contact Name', width: 270, dataType: 'string' },
{ key: 'CompanyName', headerText: 'Company Name', width: 200, dataType: 'string' },
{ key: 'Address', headerText: 'Address', width: 200, dataType: 'string' },
{ key: 'Phone', headerText: 'Phone', width: 100, dataType: 'string' }
]
}"
</table>
self.igDataSource =
new $.ig.JSONPDataSource({
dataSource: fc.ActionUrls.Pending.Tasks,
type: "remoteUrl",
responseDataKey: "Results",
});
Or
new $.ig.KnockoutDataSource({
type: 'remoteUrl',
responseDataKey: 'Results'
But keep getting:
"Cannot determine the data source type. Please specify if it is JSON or XML data."
Can someone please provide a simple sample to do this.
Thank you
Regard Christoffel
Could you post your eventhandler code that you ended up using?
Hi Todor, thanks for fixing the sample, but I needed to enable allot of remote features like remote paging and sorting on the datasource. I ended up using a generic knockout binder for jQuery Widgets to bind the igGrid to the viewmodel.
Thanks for the help.
Hi christoffelleroux ,
Sorry for the delay of the reply. I've attached your sample, but working.
You can not use remote datasource with knockout, as it's required the data to be on the page. So in that case I've used JSONPDataSource and bound the returned JSON array as a dataSouce in the data-bind attribute of the igGrid. The igGrid Knockout extension, itself internally creates igKnockoutData Source and uses Knockout Mapping to create the observable properties for each of the properties.
Thanks,
Any feedback on this?
I have attached a sample to demonstrate the issue