Many a times we place a hidden column in the kendo grid and use it’s value for performing certain operations.
You can basically place this column at any position on the columnList and retrieve it by it’s index like below:
Normally this logic works but if the grid is grouped by some columns then same number of empty columns with whom the grid is grouped will be inserted in the grid tbody at the very start.
Suppose the grid is grouped by two columns then two columns will be inserted at the starting.
In this scenario suppose we placed our hidden column at 1st place in the column list then practically it will be shifted to the first + (number of columns with which the grid is grouped) position.
so row.find(‘td:nth-child(yourColumnIndex)’).text(); will give us a wrong value.
There are two possible options for avoiding this situation:
1> Place the hidden column at the last position and try to retrieve it’s value like below:
When we place the hidden column at the last position then it does not matter that how many columns are inserted at the starting as the last column will always be a last column.
2> Above solution is the best solution in most of the situations but what if we have to place more hidden columns.
In this case we will find out the number of columns with which the kendo grid is grouped and will add this number to the hidden column original position
Hope this helps. 🙂