jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Angular 2 JQX Grid How to bind model object with Grid
Tagged: angular 2 jqx Grid
This topic contains 4 replies, has 2 voices, and was last updated by amit.dube.ms 8 years, 6 months ago.
-
Author
-
Hi
I am using JQXGrid Angular 2 Component. I have bound my model object (which is basically an array of objects) with grid.
Code to bind the data is shown below
let source = { datatype: "array", datafields: datafields, id: id, localdata:null }; if(this.localdata){ source.localdata = this.localdata; }
variable ‘this.localdata’ above is the array of model object and bound to grid. And initially ‘this.localdata’ is an empty array ‘[]’
this.localdata = []
Now I am fetching the data from server and assigning the response to the same array reference
this.ticketservice.getTicketsByfilter(filter).subscribe(tickets => { this.localdata = []; for(let i=0; i<tickets.length; i++){ let ticket = tickets[i]; if(ticket.st === 'SUSPENDED'){ ticket.suspended = true; } if(ticket.invSt === 'Scheduled' || ticket.invSt === 'Published'){ ticket.invSt = 'Submitted'; } this.localdata.push(ticket); } }
But after response is received, Grid is not showing any data.
Does Grid bind to localdata automatically.
or Is there any other way to bind an array to Grid. Please help !!!
Hi amit.dube.ms,
You should alert the grid to refresh itself.
Try with the jqxGrid method ‘updatebounddata’.Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/Hi Ivo,
I have already tried jqxGrid method ‘updatebounddata but it is not updating the data in the grid. Grid remains empty.
Moreover, I have also tried jqxGrid method ‘refresh’, that too, didnt work
Thanks
Amit DubeHi amit.dube.ms,
I do not see any jqxDataAdapter in the code provided. Are you using one. If not add it with the
autobind
property set totrue
.
Then callupdatebounddata
.Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/Thanks, It worked.
In addition to the above, I called ‘updateboundata’ with “data” as parameter, since in typescript, it will not allow calling a function without parameter.
And i need to assign data array to ‘localdata’ property of source. Code is shown below.
this.gridSource.localdata = this.accessorialCharges; this.grid.widgetObject.updatebounddata("data");
-
AuthorPosts
You must be logged in to reply to this topic.