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

Getting the parameter function name of the ajax read call

6 Answers 193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sergi
Top achievements
Rank 1
Sergi asked on 21 May 2013, 09:41 AM
I'm using the Kendo extensions for MVC and binding the grid like so:

@(Html.Kendo().Grid<AS.Model.Usuario>()
    .Name("gridUsuarios")
    .DataSource(dataSource => dataSource // Configure the grid data source
        .Ajax() // Specify that ajax binding is used
        .Read(read => read.Action("_Items", "Usuarios").Data("searchUsuariosParams")) // Set the action method which will return the data in JSON format and the function that will pass parameters
    )
    .Columns(columns =>
    {
        columns.Bound(it => it.Username).Title("Usuario");
        columns.Bound(it => it.Displayname).Title("Nombre");
        columns.Bound(it => it.Email).Title("Email");
        columns.Bound(it => it.ID).Title("").Sortable(false).ClientTemplate("#= editUsuario(data) #");
    })
    .Pageable() // Enable paging an localize it
    .Sortable() // Enable sorting
)

I need a way to get the Ajax.Read.Data function name, in this case "searchUsuariosParams" from the kendo grid javascript object.

Thanks

6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 May 2013, 06:30 AM
Hello,

 We are not sure what you need. Could you please clarify what you mean by "get the Ajax.Read.Data function name"? Please elaborate.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sergi
Top achievements
Rank 1
answered on 23 May 2013, 08:29 AM
Sorry about my english, I hope this is clearer.

I'm using the grid with ajax binding and a function called "searchUsuariosParams" that returns additional parameters for the ajax binding call.

I need a way to know from javascript the name of the function that returns the additional parameters for the ajax call, in this case I need to know that the additional parameters function is called "searchUsuariosParams".

Obviously I already know the name of the function but I'm doing unobstrusive generic methods that need to figure out the name of that function and call it.

Thanks in advance.
0
Atanas Korchev
Telerik team
answered on 23 May 2013, 10:30 AM
Hi,

 The following code should return that function:

$("#gridUsuarios").data("kendoGrid").options.dataSource.transport.read.data

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sergi
Top achievements
Rank 1
answered on 23 May 2013, 10:51 AM
Thanks, that kind of works but it returns the whole function, in this case it's returning:
function gridUsuariosParams() {
    return $("#form_search").serializeObject();
}
How can I call the function gridUsuariosParams with  $("#gridUsuarios").data("kendoGrid").options.dataSource.transport.read.data?

Is there a way that it can only return "gridUsuariosParams" instead of the whole function code block?

Thanks again.
0
Accepted
Atanas Korchev
Telerik team
answered on 23 May 2013, 10:54 AM
Hi,

 We are not sure what you are going to do with the "gridUsuariosParams" as a string. 

 You can of course call that function:

var func = $("#gridUsuarios").data("kendoGrid").options.dataSource.transport.read.data;

func();


Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sergi
Top achievements
Rank 1
answered on 23 May 2013, 11:04 AM
Thanks a lot !

I didn't know you could instantiate a function like that and call it.
Tags
Grid
Asked by
Sergi
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Sergi
Top achievements
Rank 1
Share this question
or