Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
igGrid bound to REST service url
posted

Hello,

I have an igGrid set up as the following:

window.onload = function(){
var numbers = ["0", "1", "2", "3", "4", "5", "6"];
// var dataURL = "The url of a REST service that returns data in the same form as 'data' below";
var data = [
{
"Description": "Poly over pack drum with wheels contents lavel picture and ID number",
"Quantity": "1",
"TIDnumber": "8281452"
},
{
"Description": "55 gallon steel ring top drum",
"Quantity": "1",
"TIDnumber": "8281451"
}];
$("#grid").igGrid({
virtualization: false,
autoGenerateColumns: false,
renderCheckboxes: true,
primaryKey: "TIDnumber",
columns: [{
// note: if primaryKey is set and data in primary column contains numbers,
// then the dataType: "number" is required, otherwise, dataSource may misbehave
headerText: "TIDnumber", key: "TIDnumber", width:"10%", dataType: "number"
},
{
headerText: "Description", key: "Description", width: "70%", dataType: "string"
}, {
headerText: "Quantity", key: "Quantity", width: "10%", dataType: "string"
}, {
headerText: "Amount Needed", key: "AmountNeeded", width: "10%", dataType: "string", unbound: true
}
],
dataSource: data, //JSON Array defined above //where i have been putting dataURL
dataRendered: function (evt, ui) {
ui.owner.element.find("tr td:nth-child(1)").css("text-align", "center");
ui.owner.element.find("tr td:nth-child(2)").css("text-align", "left");
ui.owner.element.find("tr td:nth-child(3)").css("text-align", "center");
ui.owner.element.find("tr td:nth-child(4)").css("text-align", "center");
},
dataSourceType: "json",
width: "100%",
tabIndex: 1,
features: [
{
name: 'Responsive',
enableVerticalRendering: false,
columnSettings: [
{
columnKey: 'TIDnumber',
classes: 'ui-hidden-phone'
},
{
columnKey: 'Description',
classes: 'ui-hidden-phone'
},
{
columnKey: 'Quantity',
classes: 'ui-hidden-phone'
},
{
columnKey: 'AmountNeeded',
classes: 'ui-hidden-phone'
}
]
},
{
name: "Selection",
mode: "row"
},
{
name: "Updating",
enableAddRow: false,
editMode: "rowedittemplate",
rowEditDialogWidth: 280,
rowEditDialogHeight: '280',
rowEditDialogContentHeight: 300,
rowEditDialogFieldWidth: 150,
rowEditDialogContainment: "window",
rowEditDialogRowTemplateID: "rowEditDialogRowTemplate1",
enableDeleteRow: false,
showReadonlyEditors: false,
showDoneCancelButtons: true,
enableDataDirtyException: true,
columnSettings: [
{
columnKey: "TIDnumber",
readOnly: true
}, {
columnKey: "Description",
readOnly: true
},
{
columnKey: "Quantity",
readOnly: true
},
{
columnKey: "AmountNeeded",
editorType: "text",
editorOptions: {
button: "dropdown",
listItems: numbers,
readOnly: true,
dropDownOnReadOnly: true
}
}
]
}
]
});
}

for some reason the Grid will bind to the variable data but not dataURL even though the data that is returned from that URL is the same formatting as the data variable.

Any help would be greatly apprectiated,

Thanks!

Jake :)

Parents
  • 18204
    Offline posted

    Hello Jake,

     

    I have created a sample using the code you provided along with a WebAPI service.  When I set my igGrid's dataSource to the WebAPI url, I get the data I am expecting.  I have attached my sample to this post as a demonstration.

    As for why this is not working on your end, it would help to check your network traffic to see if the REST call is returning any errors while trying to bind the data.  Please check your network traffic and let me know what data is being returned in the response.  Also let me know if you are receiving any javascript errors either through a popup or through your browser's console.

    Since we may have some differences in our REST setup, you may need to configure some additional settings.  The igGrid does have a restSettings object option for configuring REST settings.  You may need to set these to fit your scenario.  You can more information on this here:

    http://www.igniteui.com/help/iggrid-rest-updating

    http://help.infragistics.com/jQuery/2014.2/ui.iggrid#options:restSettings

    If you need further assistance with this, please let me know.

    RESTDataBinding.zip
Reply Children