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

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

1 Answer 748 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 19 Oct 2012, 05:40 PM
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.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Oct 2012, 11:38 AM
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!
Tags
Grid
Asked by
Sam
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or