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

Dynamic size of grid

1 Answer 431 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ric
Top achievements
Rank 1
Ric asked on 15 Sep 2015, 10:05 AM

I have the following grid

<div class="actualGrid" id="actualGrid">
        @(Html.Kendo().Grid<AVNO_KPMG.Models.Bench>()
            .Name("grid")
 
        .Columns(columns =>
        {
            columns.Bound(p => p.name).Title("Bench").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains"))).Width(125);
            columns.Bound(p => p.freeSeats).Title("Free Seats").Width(350);
 
            columns.Command(command => { command.Custom("checkBench1 ").Text(" AM ").Click("doCheckIn"); command.Custom("checkBench 2").Text(" PM ").Click("doCheckIn"); command.Custom("checkBench3").Text("All Day").Click("doCheckIn"); }).Width(250).Title("Check in");
 
        })
 
 
        //.Editable(editable => editable.Mode(GridEditMode.PopUp))
        .Pageable()
        .Sortable()
 
        .Scrollable()
                .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
        .HtmlAttributes(new { style = "height:530px;" })
                .Events(events => events.DataBound("onDataBound"))
        .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Events(events => events.Error("error_handler"))
        .Model(model => model.Id(p => p.id))
                        .Read(read => read.Action("GetBenches", "Home"))
 
 
                )
        )
    </div>

 I would like to know if there is a way to change the size of the grid according to the number of results i have when i use filter

for Example if i filter first column and get 1 result grid would be small, and if i had 10 results i would be larger.

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 17 Sep 2015, 06:47 AM
Hi Ric,

Thank you for contacting us.

If you remove the scrolling and the height of the grid set in the HtmlAttributes options:
.HtmlAttributes(new { style = "height:530px;" })
the grid will have height which is the sum of wall rows height. On the following link you can check a simple example which demonstrates this.
http://dojo.telerik.com/OfUQa

Also you can check following forum thread which elaborates on the dynamic grid height:
http://www.telerik.com/forums/dynamic-grid-height

I hope this helps.

Regards,
Radoslav
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Ric
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or