开发者

Telerik MVC grid-How to set default row selected

Is it possible to render a Grid with one row selected as default (set the right page 开发者_JAVA技巧number and highlight the row)?


For highlighting, try using the "OnRowDataBound" event

.ClientEvents(events => events.OnRowDataBound("onRowDataBound"))

with something like

function onRowDataBound(e) {
    var myId = $('#MyId').val();

    if (e.dataItem.Id == myId)
        e.row.className = 't-state-selected';
}

I'm still trying to figure out how to set the correct initial page number. This bloke might be on to something.


Use the Grid RowAction method, eg:

.RowAction(row => row.Selected = row.DataItem.CustomerCode.Equals(ViewBag.ID))


It is perhaps possible if you iterate in the grid source, locate the row which has to be selected in it, than use a formula to detect on which page will be displayed, and finally change the page index on initial load and select it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜