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

Refresh Grid

2 Answers 362 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Malte
Top achievements
Rank 1
Malte asked on 04 Dec 2012, 09:32 AM
Hi!

I want the grid to update after i selected a new value in the dropdown. How is this done?

Here is part of the code:

<script type="text/javascript">
$(document).ready(function () {
            $('#filter').change(function () {
                //Refresh data
//Change datasource(?) to new controller, action and routeValue?
                $("#grid").?????; //Want to reload data...
            });
        });
</script>admin


 <select id="filter" >
        <option value="1">One</option>
        <option value="2">Two</option>
        <option value="3">Three</option>
    </select>

<%: Html.Kendo().Grid(Model)
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.PremieTrappaRadID).Hidden();
        columns.Bound(p => p.Age);
        columns.Bound(p => p.BB_0_7_5);
        columns.Bound(p => p.BB_7_5_7_5);
        columns.Bound(p => p.BB_7_5_20);
        columns.Bound(p => p.BB_20_30);
        columns.Bound(p => p.BB_30_50);
        columns.Bound(p => p.BB_50);
    })
    .Pageable()
    .Sortable()
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Action", "Controller",  new { id= 1})) //route value I want to change.
     )
%>

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 Dec 2012, 07:54 AM
Hello,

The route values are set only once during the initialization. To send the data dynamically on the client you should use the request Data function like described the in the Ajax section of this documentation topic. To trigger a new request when the value changes, you could use the Grid dataSource.read method in the change event.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Maxime
Top achievements
Rank 1
answered on 26 Jan 2018, 06:10 PM

Server:

.Read(read => read.Action(readActionName, controllerName, new { year = Model­.SelectedDate.Year, month = Model­.SelectedDate.Month, day = Model­.SelectedDate.Day }))

 

Client:

function refreshGridEmployees(year, month, day) {
var gridEmployees = $("#gridEmployees").data("kendoGrid");

gridEmployees.dataSource.read({ year: year, month: month, day: day });
}

Tags
Grid
Asked by
Malte
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Maxime
Top achievements
Rank 1
Share this question
or