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

Grid without Ajax

1 Answer 633 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 05 Sep 2013, 01:04 AM
I'm trying to learn both Kendo and MVC at the same time, so bear with me.  In the code below, I know I could populate my grid via Ajax and frankly I'd be more comfortable with that, but I'm trying to acquaint myself with the basics, so I'd like to avoid it for now.

I would like the contents of my Grid to be restricted by both a DropDownList and a Search box.  The issue is that when you turn on Pageable for a Kendo Grid, it wants to GET the next page.  But since my DropDownList and my Search box will not be part of the GET params, they won't be available to the Action.  So the question:

Is it hopelessly naive to use Grid without Ajax or is there a straightforward way to either include my additional parameters or make the pagination use the form POST?

@using (Html.BeginForm(null, null, FormMethod.Post, new { id="searchForm" })) {
   <script>
      function submit() { $("#searchForm").submit() }
   </script>
   @(Html.Kendo().DropDownListFor(m => m.ListID).DataValueField("ID").DataTextField("Name")
         .BindTo(Model.Lists).Events(e => e.Change("submit")))
   @Html.Kendo().AutoCompleteFor(m => m.SearchText).Placeholder("Search")
   <input type="submit" value="Search" />
   @Html.Kendo().Grid(Model.Albums).Name("AlbumsGrid").BindTo(Model.Albums).Pageable().Sortable()
}

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 06 Sep 2013, 03:06 PM
Hello Kevin,

Of course your scenario is completely valid, you can send those parameters automatically to the server each time when a pagination request is performed.

This is configured through the data function of the read configuration of the dataSource. Check the example here:

http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/faq#how-do-i-send-values-to-my-action-method-when-binding-the-grid?

http://docs.kendoui.com/api/framework/datasource#configuration-transport.read.data

I hope this is what you are looking for.

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
Kevin
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or