jQuery UI Widgets › Forums › Grid › grid column with format
This topic contains 6 replies, has 3 voices, and was last updated by Dimitar 10 years, 2 months ago.
-
Authorgrid column with format Posts
-
Hi,
My 2 column (which are computed) values in the grid is getting committed to database as zero / 0. Although the grid displays correct values.
below is the code{ text: ‘Margin’, editable: false, datafield: ‘Mgn’,width: 65,
cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
if ((parseFloat(rowdata.FinalRSP)>0) && parseFloat(rowdata.EstTerrLndCst)>0)
{
var FinalRSPNetVat=((parseFloat(rowdata.FinalRSP)*100)/(100+parseFloat(rowdata.VATPer)));
var mrgn = ((parseFloat(FinalRSPNetVat)-parseFloat(rowdata.EstTerrLndCst))/parseFloat(FinalRSPNetVat))*100;
return “<div class=’jqx-right-align’>” + dataAdapter.formatNumber(mrgn, “p2”) + “</div>”;
}
}
},
{ text: ‘Markup’, editable: false, datafield: ‘Mup’,width: 65,
cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata)
{
if (parseFloat(rowdata.FinalRSP)>0 && parseFloat(rowdata.EstTerrLndCst)>0)
{
var FinalRSPNetVat=((parseFloat(rowdata.FinalRSP)*100)/(100+parseFloat(rowdata.VATPer)));
var mrkup = ((parseFloat(FinalRSPNetVat)-parseFloat(rowdata.EstTerrLndCst))/parseFloat(rowdata.EstTerrLndCst))*100;
return “<div class=’jqx-right-align’>” + dataAdapter.formatNumber(mrkup, “p2”) + “</div>”;
}
}`Please note hthe formatNumber is “p2”. Please advice
Repasting the code
{ text: 'Margin', editable: false, datafield: 'Mgn',width: 65, cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { if ((parseFloat(rowdata.FinalRSP)>0) && parseFloat(rowdata.EstTerrLndCst)>0) { var FinalRSPNetVat=((parseFloat(rowdata.FinalRSP)*100)/(100+parseFloat(rowdata.VATPer))); var mrgn = ((parseFloat(FinalRSPNetVat)-parseFloat(rowdata.EstTerrLndCst))/parseFloat(FinalRSPNetVat))*100; return "<div class='jqx-right-align'>" + dataAdapter.formatNumber(mrgn, "p2") + "</div>"; } } }, { text: 'Markup', editable: false, datafield: 'Mup',width: 65, cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { if (parseFloat(rowdata.FinalRSP)>0 && parseFloat(rowdata.EstTerrLndCst)>0) { var FinalRSPNetVat=((parseFloat(rowdata.FinalRSP)*100)/(100+parseFloat(rowdata.VATPer))); var mrkup = ((parseFloat(FinalRSPNetVat)-parseFloat(rowdata.EstTerrLndCst))/parseFloat(rowdata.EstTerrLndCst))*100; return "<div class='jqx-right-align'>" + dataAdapter.formatNumber(mrkup, "p2") + "</div>"; } }
Hello dippy,
Your question is not clear. try to make a demo in http://jsfiddle.net
Thank you,
Supun SilvaHello dippy,
A computed column, as implemented in the demo of the same name, does not have actual cell values (it is not bound to an existing datafield). Cells only appear to have values through cellsrenderer but they cannot be used for commit to database, sort or any purpose other than viewing.
Some other suggestions on computed column implementation can be found in the forum topic Computed Column that will sort and use the cellclass.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Dear Dimitar,
Thanks for your reply. I have database fields for the 2 computed columns mentioned above, grid displays correct data as % and when commit i can see a value zero value getting committed in alert message. The database also shows zero value. M
Below is the code
updaterow: function (rowid, rowdata, commit) { var data = "update=true&" + $.param(rowdata); alert(data);
My problem is it does not show correct % value in the alert message.Other columns values are correct. Do i need to bind the computed data values explicitly.
Please advice.
regards
Hi
Any help ? Please
Hi dippy,
Are the displayed cell values of your computed columns loaded from the database or computed through cellsrenderer? In the latter case, please read my previous post again and refer to the linked topic for possible solutions.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.