Hi expert
How can I add row number to JS-Grid just like jqgrid?
in one of my projects I need this functionality.
thanks.
You just have to indicate the field type to number: type: "number"
Hi xuanxoo
I mean index row; not type of number. like this image : https://i.stack.imgur.com/05beP.png
RowRenderer has a RowIndex param. You could try to use it as row-num.
yep, you can try something like this :
rowRenderer: function (item, itemIndex) {
return $("
@mohammdr, please, checkout the following issue https://github.com/tabalinas/jsgrid/issues/430.
Have a global variable ie rowNum :
var rowNum = 0;
....
...
Then when initializing table add a field :
fields: [
{
title: "#", type: "number", itemTemplate: function (value, item) {
rowNum += 1;
return rowNum;
}
}, ......
Finally, reset this variable on each refresh (like sorting etc)
onRefreshed: function (args) {
rowNum = 0;