jQWidgets Forums
jQuery UI Widgets › Forums › Grid › jqxgrid: How to apply some properties such as renderer… for dynamic columns
Tagged: angular grid, bootstrap grid, dynamic, javascript grid, jquery grid, jqwidgets grid, jqxgrid
This topic contains 4 replies, has 2 voices, and was last updated by BNK 8 years, 11 months ago.
-
Author
-
April 27, 2016 at 3:04 am jqxgrid: How to apply some properties such as renderer… for dynamic columns #83900
Hi All! I currently use
jQWidgets v3.9.1
in my project
I have succesfully used it for dynamic columns as below:... dataAdapter = new $.jqx.dataAdapter(source, { formatData: function (data) { return JSON.stringify(postdata); }, downloadComplete: function (data, status, xhr) { // dynamic columns var json = JSON.stringify(data); var obj = $.parseJSON(json); for (var i in obj[0]) { datafields.push({ name: i }); columns.push({ text: i, datafield: i }); } ... }, loadError: function (xhr, status, error) { alert(xhr.status + ' ' + status + ' ' + source.data); } }); ... $("#jqxgrid").jqxGrid( { ... source: dataAdapter, ... columns: columns });
However, I don’t know how to apply some properties such as
pinned: true, filtertype: 'date', renderer: columnrenderer, cellsalign: 'center', cellsformat: 'dd/MM/yyyy'
for some of the columns.Could you please tell me how to do that? Thanks in advance.
April 27, 2016 at 5:53 am jqxgrid: How to apply some properties such as renderer… for dynamic columns #83909Hello BNK,
You could use setcolumnproperty property from the Grid.
Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comApril 27, 2016 at 6:40 am jqxgrid: How to apply some properties such as renderer… for dynamic columns #83913Hi Hristo!
Thank you, it works!
However, if I put$('#jqxgrid').jqxGrid('setcolumnproperty'...
lines inside$("#jqxgrid").bind('bindingcomplete', function () {...});
then the grid takes longer time to display data. Any suggestion?April 27, 2016 at 7:39 am jqxgrid: How to apply some properties such as renderer… for dynamic columns #83918Hi Hristo!
One more thing,
$('#jqxgrid').jqxGrid('setcolumnproperty', 'EndDate', 'cellsformat', 'dd/MM/yyyy');
is not working, it displays2016-05-07T00:00:00
UPDATE: I can fix this issue by using
datafields.push({ name: i, type: (i === 'EndDate')? 'date' : 'string' });
April 28, 2016 at 3:05 am jqxgrid: How to apply some properties such as renderer… for dynamic columns #83951Hi All!
If using
$('#jqxgrid').jqxGrid('setcolumnproperty'
… lines inside$("#jqxgrid").bind('bindingcomplete', function () {...});
, my app got poor performance at first run (ajax requests later is faster). So I have finally solved this performance issue by using the abovedataAdapter = new $.jqx.dataAdapter(source, { formatData: function (data) { return JSON.stringify(postdata); }, downloadComplete: function (data, status, xhr) { // dynamic columns var json = JSON.stringify(data); var obj = $.parseJSON(json); for (var i in obj[0]) { datafields.push({ name: i, type: (i === 'EndDate')? 'date' : 'string' }); columns.push({ text: i, datafield: i, filtertype: (i === 'EndDate') ? 'date' : 'string', pinned: ($.inArray(i, ['Code', 'Desc', 'Status', 'Date']) !== -1) ? true : false, cellsformat: (i === 'EndDate') ? 'dd/MM/yyyy' : '', }); } if (!source.totalRecords) { source.totalRecords = data.length; } }, loadError: function (xhr, status, error) { alert(xhr.status + ' ' + status + ' ' + source.data); } });
Thankyou!
-
AuthorPosts
You must be logged in to reply to this topic.