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

Selectable Grid with a table inside.

0 Answers 41 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.
Juan Pablo Perez
Top achievements
Rank 1
Juan Pablo Perez asked on 05 Sep 2011, 06:15 PM
Hello,

I'm writing a solution with a kind of CMS. The project includes a search button, when someone click on this button the records from content are returned to a grid. When the record is selected is sent to the action related to the content.

The code I used to do that is:
@(Html.Telerik().Grid(Model.Models)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(o => o.Action).Hidden(true);
            columns.Bound(o => o.Content).Title("")
                .ClientTemplate("<div class='SearchResult'><#= Content #></div>");
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax().Select("SearchGrid", "Contents");
        })
        .Selectable()
        .ClientEvents(events => events
            .OnDataBinding("OnDataBindingHandler")
            .OnRowSelect("OnRowSelectedHandler")
        )
        .Pageable(paging => paging.Enabled(true))
        .Footer(true)
)

Content is the column with the content value and Action is the column with the action related to de Content.

The problem is when the Content column contains a table. I think when you select a record in the grid the class t-state-selected is assigned to the tr related to the record selected. The problem in this case, when the content has a table, is that instead of assigning this class to the tr of the Grid, sometimes it is assigned to a tr inside the table of the content.

So when you try to obtain the hidden value of the Action column it is obtained the value of the first column of the Content table inside instead of the desired value.

The code to obtain the Action value is:

function OnRowSelectedHandler(e) {
            var action = e.row.cells[0].innerHTML;
            var urlRoot = $('#UrlRoot').val();
            location.href = urlRoot + action;
        };

I don't know if there is another way to obtain the hidden value related to the current record or maybe it is a bug in the telerik grid.

Thanks in advance.

Juan Pablo PĂ©rez
Tags
Grid
Asked by
Juan Pablo Perez
Top achievements
Rank 1
Share this question
or