Jsgrid: row number in grid

Created on 22 Feb 2017  路  6Comments  路  Source: tabalinas/jsgrid

Hi expert
How can I add row number to JS-Grid just like jqgrid?
in one of my projects I need this functionality.
thanks.

help wanted

All 6 comments

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 $("").append("").append(itemIndex);
}

@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;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RevealedFrom picture RevealedFrom  路  3Comments

julmot picture julmot  路  3Comments

andymacourek picture andymacourek  路  3Comments

git265 picture git265  路  5Comments

venkatesh333 picture venkatesh333  路  4Comments