Passing data in the js function handler of the Data() function

2 posts, 0 answers
  1. Sam
    Sam avatar
    22 posts
    Member since:
    May 2012

    Posted 19 Oct 2012 Link to this post

    good morning everyone,

    how are you?  I am currently using the licensed version of Kendo UI Complete for ASP.NET MVC (Q2 2012) and trying to figure out the correct way to pass additional data parameters to the server using the Data() function of the grid.

    Below is my setup for the Kendo UI Wrapper grid.

    @(Html.Kendo().Grid<ViewModel>()
        .Name("grdAllWebsites")
        .Columns(columns =>
        {
            ...
        })
        .DataSource(dataSource =>
    {
    dataSource.Ajax()
    .Model(model =>
    {
    // DataKey
    model.Id(o => o.Id);
    })
    .PageSize(10)
    .Create(create => create.Action("Create", "Home").Data("CreateJS"))
    })
        .Pageable(paging =>
        {
            ...
        })
        .Sortable(sortable =>
        {
            sortable.SortMode(GridSortMode.MultipleColumn);
        })
        .Filterable()
    )

    and here is my js function:

    CreateJS: function (e) {
     
            var args = arguments;
            var subjectCode = $('#subjectCode').val();
            var isActive = $('#isActive').val();
     
            this.url += ("?subjectCode=" + subjectCode + "&isActive=" + isActive);
        }

    right now, i am using query string to pass additional data/parameters to the server but is there a better or correct way to pass the additional parameters to the server?  I tried looking at the API documentation but there wasn't an example on a good/correct way to do this:

    http://docs.kendoui.com/api/wrappers/aspnet-mvc/Kendo.Mvc.UI.Fluent/CrudOperationBuilder#datasystemstring

    thank you very much for your help.
  2. Daniel
    Admin
    Daniel avatar
    2224 posts

    Posted 24 Oct 2012 Link to this post

    Hello Sam,

    In order to pass additional data with the request, you should return an object with the parameters as result of the function. Please check this documentation topic for information and a sample.

    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!
Back to Top