Click here to Skip to main content
15,070,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the grid below and i want to get the rows and columns of the grid and also get the values of every cell through javascript...

C#
@html.grid(model).columns(columns>RenderValueAs(o => @Html.CheckBox("checkBox", false));                                 
columns.Add(c => c.Name).Titled("BookName");                                  
columns.Add(c => c.Tittle).Titled("BookTittle");                                 
columns.Add(c => c.Author).Titled("BookAuthor");                               }).WithPaging(10).Sortable(true)
Posted
Updated 31-Dec-14 23:59pm
v2
Comments
joshrduncan2012 26-Dec-14 13:20pm
   
So what is your question?
Member 10565777 26-Dec-14 15:20pm
   
How can i get the Row through the java script from the grid when the check box is checked.. i am unable to access this grid through java script

Yes Tadit is correct. You can attach an event to the checkbox check and with the element (checkbox) you can access the specific row where the checkbox is checked. You can use something like below using Jquery:-

C#
$(element).target.closest('tr'); 
//Gets the row <tr>..</tr>
$(element).target.closest('tr').find('td:eq(0)');
//Gets the first column of row<td>..</td>


I hope you get this.
Please post back your queries if any.
Thanks.:)
   
v2
Grid is renders as HTML table. So, you can easily attach an checkbox change event using jQuery and inside that event, get the current tr (table row) and then the values inside that.

You can attach the event for all the checkboxes inside the Grid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900