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

[Solved] Display record details on row select?

1 Answer 52 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.
Shea
Top achievements
Rank 1
Shea asked on 28 Mar 2011, 06:44 PM
Hello,

My model has too many fields to display in a grid. I would like to change my grid to only show a few fields (already did this), and then when a row in table is selected, have it display the details of that record below in non tabular form.  Selecting another item in the grid then causes the details to update to reflect the newly selected item.

I know how to hook up a row selected event, but not sure what is the best path to take after that:

Html.Telerik().Grid<Person

>(Model)

 

 

.Name(

"People")

 

 

.Footer(Model.Count() > 10)

 

.Columns(c =>

 

{

 

    c.Bound(m => m.Name)

;
    c.Bound(m => m.Number);

 

 

})

 

.Selectable()

 

.Pageable()

 

.ClientEvents(events => events.OnRowSelected(

"onRowSelected"))

 



<

 

script type="text/javascript">

 

    function onRowSelected(r)
   {
       //does r contail all data in model, or just bound columns?
       //how can I list details about person under telerik grid?
   }
</script>


I have seen the live demo for Grid->Selection->Client Selection, but this doesn't quite work because I don't want to use another table, I want to list the details something like:
First Name: Doug
Last Name: Smail
Occupation: Hockey Player
Team: Vancouver
etc: etc

Thanks,
~S

1 Answer, 1 is accepted

Sort by
0
Shea
Top achievements
Rank 1
answered on 28 Mar 2011, 10:30 PM
Figured it out.

Hand to a load on the div section in my js callback:
function onRowSelected(e)
{
   var x = $('#results')
   x.load( '<%= Url.Action("SomeAction", "MyCtrlr") %>', { itemId: e.row[0].innerHTML});
}
  
  
  
<div id="results"></div>
Tags
Grid
Asked by
Shea
Top achievements
Rank 1
Answers by
Shea
Top achievements
Rank 1
Share this question
or