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

Expand the first row initially using MVC + Server Binding

1 Answer 318 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 2
Ian asked on 20 Aug 2013, 08:32 PM
I have a Hierarchical grid that is bound to the server and is in MVC  (.DataSource(d => d.Server()))  

When the grid first loads I'd like the grid to expand the first row by default so the detail view is showing.

Can this be done without Javascript (preferred) or in Javascript if needed.


1 Answer, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 22 Aug 2013, 11:34 AM
Hello Ian,

If JavaScript is not enabled for the browser the DetailViews cannot be opened by the end user. The JavaScript that you will need to make the first enabled is as follows:

@model IEnumerable<Kendo.Mvc.Examples.Models.Product>
 
@(Html.Kendo().Grid(Model)   
    .Name("Grid")
    .Columns(columns => {
        columns.Bound(p => p.ProductID).Groupable(false);
        columns.Bound(p => p.ProductName);
        columns.Bound(p => p.UnitPrice);
        columns.Bound(p => p.UnitsInStock);
    })
    .DetailTemplate(@<text>
        This should be expanded
    </text>)  
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .Groupable()
)
 
 
<script type="text/javascript">
    $(function () {
        $('#Grid').data('kendoGrid').expandRow($('#Grid tbody>tr:first'));
    })
</script>


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Ian
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Share this question
or