Refresh Grid

3 posts, 0 answers
  1. Malte
    Malte avatar
    1 posts
    Member since:
    Nov 2012

    Posted 04 Dec 2012 Link to this post

    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. Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 06 Dec 2012 Link to this post

    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!
  3. Donald
    Donald avatar
    2 posts
    Member since:
    Dec 2017

    Posted 26 Jan 2018 in reply to Malte Link to this post

    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 });
    }

Back to Top