This is a migrated thread and some comments may be shown as answers.

[Solved] Access by Column Name rather than Ordinal in RowDataBound

6 Answers 136 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dan
Top achievements
Rank 1
Dan asked on 09 Jan 2012, 12:31 AM
How can we access a cell in the row  by name rather than ordinal?  In the pseudo code:

 

function RowDataBound(e) {

var

 

 

row = e.row;


row.cells[4].innerHTML= "foo"

if groupgin is enabled then cells[4] can change.  How do we access this by name instead of ordinal?

 

 

6 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 09 Jan 2012, 09:27 AM
Hello Dan,

You can use the snippet bellow to achieve this:
var grid = $(this).data("tGrid");
 
var column = grid.columnFromMember("ContactName"), // -> column member
      index = $.inArray(column, grid.columns);
 
var td = tr.children(":not(.t-group-cell)")[index];


Regards,
Nikolay Rusev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Dan
Top achievements
Rank 1
answered on 09 Jan 2012, 04:27 PM

Hello Dan,

You can use the snippet bellow to achieve this:

vargrid = $(this).data("tGrid");

 

varcolumn = grid.columnFromMember("ContactName"), // -> column member

      index = $.inArray(column, grid.columns);

 

vartd = tr.children(":not(.t-group-cell)")[index];

 
 
.
NIkolay - i am getting TR is undefined.  Can you help me?  It looks like the snippet is incomplete.

Dan
0
Nikolay Rusev
Telerik team
answered on 09 Jan 2012, 05:36 PM
Hello Dan,

tr in the context of the RowDataBound is e.row.

Regards,
Nikolay Rusev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Mahesh
Top achievements
Rank 1
answered on 10 Aug 2012, 06:48 AM
Hello  Nikolay ,

Is it possible to avoid or Ignore case checking (Upper Case or Lower Case)of column name  during getting the Id form column Name...In the folllwoing code snippet


vargrid = $(this).data("tGrid");

 

varcolumn = grid.columnFromMember("ContactName"), // -> column member

      index = $.inArray(column, grid.columns);

 

vartd = tr.children(":not(.t-group-cell)")[index];



Thanks,
Mahesh

  

0
Nikolay Rusev
Telerik team
answered on 10 Aug 2012, 07:53 AM
Hello Mahesh,

The only way is if you have own implementation of columnFromMember function. This is trivial job to do - simply iterate through grid.columns list and compare the member field.

Greetings,
Nikolay Rusev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Mahesh
Top achievements
Rank 1
answered on 11 Aug 2012, 07:52 AM
Hello  Nikolay,

Thanks for your reply....

I have another question

How can I use Header Template as used in Server Binding of Telerik Grid of MVC for Ajax Binding...

I want like following format

    Name                          Address
Fname         Sname           City State

and at the time of edit or add i want to add the data for Fname,Sname,City and Address



Please Help Me........I am waiting for your reply


Thanks in advance.......


Please tell me is it possible or not.................... 
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Dan
Top achievements
Rank 1
Mahesh
Top achievements
Rank 1
Share this question
or