jQWidgets Forums
jQuery UI Widgets › Forums › Angular › Set localdata in Dynamically created grid
Tagged: jqxGrid ;
This topic contains 2 replies, has 2 voices, and was last updated by gudboisgn 7 years, 3 months ago.
-
Author
-
I have Created Grid Columns Dynamically, that work fine and grid header render succesfully, but, when i set localdata of grid, it doesnot display the grid data. I console.log(this.dynamicSource); shows datafield & localdata in console. but grid is not loaded with data.
// grid Datafield source
this.dynamicSource = { datatype: 'json', datafields:[], localdata: [], updaterow: (rowid: any, rowdata: any, commit: any): void => { commit(true); }, };
// grid Column
dynamicColumn:any = [ { text: 'Sn', sortable: false, filterable: false, editable: false, groupable: false, draggable: false, resizable: false, datafield: 'sn', columntype: 'number', width: 50, cellsrenderer: (row: number, column: any, value: number): string => { return '<div style="margin: 4px;">' + (value + 1) + '</div>'; } } ];
//Create Dynamic Grid
`createGrid(data){
for(let i = 0; i < data[‘subjects’].length; i++){
let newCol = {
text: data[‘subjects’][i][‘name’], datafield: data[‘subjects’][i][‘code’]+’_mark’, columntype: “textbox”
};this.dynamicColumn.push(newCol);
this.dynamicSource.datafields.push({ name: data[‘subjects’][i][‘code’]+’_mark’, type: ‘number’ });
}
this.dynamicSource.localdata = data[‘students’];
this.dynamicAdapter = new jqx.dataAdapter(this.dynamicSource,{autoBind: true,});
this.examSubjectGrid.updatebounddata();
console.log(this.dynamicSource);
}`
Hello gudboisgn,
Have you tried refreshing the grid after you update the DataAdapter?
Try with this:ngAfterViewInit(): void { this.myGrid.refresh(); }
Best Regards,
StanislavjQWidgets Team
http://www.jqwidgets.com/Hello Stanislav,
I tried to refresh grid after updating DataAdapter, like this shown below but column header get rendered but none of the localdata are being rendered.
i have tried.this.dynamicSource.localdata = data['students']; this.dynamicAdapter = new jqx.dataAdapter(this.dynamicSource,{ autoBind: true, }); this.examSubjectGrid.refresh();
I have also, tried:
this.examSubjectGrid.refreshData(); this.examSubjectGrid.render();
-
AuthorPosts
You must be logged in to reply to this topic.