KENDO UI TIP 4 : Getting cell values by Column number In Kendo Grid

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:

Untitled

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.

Solutions:


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:

Untitled2

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

Untitled2

Hope this helps. 🙂

Advertisements

One thought on “KENDO UI TIP 4 : Getting cell values by Column number In Kendo Grid

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s