jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Round grid column
Tagged: jquery grid formatting
This topic contains 8 replies, has 2 voices, and was last updated by plgeda 11 years, 6 months ago.
-
AuthorRound grid column Posts
-
Hi,
Can any one please tell me ,How can i do this?.
I have a column,which represents quantity of items.
Here is my code,` { name: ‘quantity’, type: ‘number’ },
{ text: ‘Quantity’, datafield: ‘quantity’, width: 130 , minwidth: 130,cellsformat:”d2″}`I have formatted my column using d2.
Now the problem is ,If the quantity is 10 (it has no decimal part),the grid will be showing a decimal number 10.00.
How can i solve this issue..
I mean if the value is 10,then the display will be 10.
if the value is 10.12311,then the display will be 10.12.Thanks,
Hi plgeda,
I suppose that you should use the “f” format string instead.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/OK thank you Peter Stoev..
Now at grid loading time it is ok..but after i perform a grid inline edit, it does not work.
I mean if edited 10 as 10.232212,then it returns 10.232212..i need to display 10.23.
Thanks
Hi plgeda,
That is how the formatting works. If your format string is “f2” then all you columns would have 2 decimal places including numbers like “10” which would be displayed as “10.00”.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/That is ok..but my need is if the quantity has no decimal part,Then it wll be displayed as a non decimal number..
Can i possible with this?
Thanks,Hi plgeda,
The quantity usually should be integer i.e you should not have decimal part in quantity, which means that the format should be “d”.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comOk..can you please tell me how can i set a value for a edited cell.
After i perform an inline editing i need to round that value and set into that cell.
here is my code.
$(“#itemDetailsGrid”).on(‘cellendedit’, function (event) {
var value = args.value;
$(“#itemDetailsGrid”).jqxGrid(‘setcellvalue’, args.rowindex, “quantity”, roundValue(value));//roundValue is a method which return a number.
});
But it is not working..
ThanksHi plgeda,
I am not sure what roundValue is, because we do not have such API in our Grid. This sample: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/cellcustomediting.htm?arctic shows how to customize the Grid’s editing and/or editors. As you can see in the demo’s code, the “geteditorvalue” enables you to customize the edited value, before closing the editor.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/roundValue is just a method
var roundValue=function(num){
return (num.toString().indexOf(“.”) !== -1) ? num.toFixed(2) : num;
};if we pass 10.23232 ,it returns 10.23
if we pass 10, it returns 10Thanks
-
AuthorPosts
You must be logged in to reply to this topic.