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

[Solved] Help Configuring Ajax Binding for Additional Arguments

3 Answers 179 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kevin Burandt
Top achievements
Rank 1
Kevin Burandt asked on 04 Apr 2011, 02:03 AM
I have a master-detail grid using Ajax hierarchy that works fine, the inner grid binds properly to the selected row.  I now want to pass a query string (entered by user) from the master grid to the controller so I can filter results.  The code below works fine except that I can't figure out how to get it to bind data from user input instead of what's in ViewData.

<%= Html.Telerik().Grid(Model)
        .Name("Orders")
        .DataBinding(dataBinding => dataBinding
             //Ajax binding
             .Ajax()
                   //The action method which will return JSON and its arguments
                   .Select("_AjaxBinding", "Home", new {id = (string)ViewData["id"]})
        )
        .Pageable()
        .Sortable()

Given this html
@Html.TextBox("nameFilter", "Search")

I would like to see
POST http://localhost:55911/Job/_JobList?nameFilter=Search

This obviously comes across as a string:
.Select("_JobList", "Job",  new {nameFilter = "#= JobName #" }))

With Ajax binding how do I get user selection criteria back to the controller?

Thanks,

Kevin

3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 04 Apr 2011, 08:02 AM
Hello Kevin Burandt,

 You can do this by handling the OnDataBinding JavaScript event and pass the additional argument via the data field of the event arguments:

function onDataBinding(e) {
   e.data = { id: $("#searchBox").val() };
}

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kevin Burandt
Top achievements
Rank 1
answered on 04 Apr 2011, 01:44 PM
Atanas,

Thank you works great!

Kevin
0
Bob
Top achievements
Rank 1
answered on 06 Apr 2012, 07:04 PM
Is there anyway to tell the grid to ignore the error if the function does not exist?

i want to create a generic "picklist" grid which is used on multiple forms. On some forms I may want to add additional filtering parameters. So, I want to specify an onDataBinding function name but would only provide it on forms where I wanted to add these parameters?

BOb

EDIT: I worked around this by creating a proxy js function that checked for the existence of another function before calling it for now.
Tags
Grid
Asked by
Kevin Burandt
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Kevin Burandt
Top achievements
Rank 1
Bob
Top achievements
Rank 1
Share this question
or