Question

in telerik extenstion to pass additional data to ajax request I used

function onDataBinding(e)
{
    e.data = {argument : 4};
}

where e was div cointainer with data object inside, How can I do this using kendo ? I tried the same but for Kendo e arqument is sth totally different.

Was it helpful?

Solution

finally i got the answer my own and it is :

$('#grid').data('kendoGrid').dataSource.Read({name:value})

OTHER TIPS

Sorry for the terrible late at the party, but i've got some special cake that you may find tasty:

function readData()
{
    return {
        anagId: selectedItem.ID
    };
}

    $("#grid").kendoGrid({
        dataSource: {
            type: "ajax",
            transport: {
                read: {"url":"@Url.Action("RecordRead", "Tools")","data":readData} 
        }
       [ rest of the grid configuration]

I came across this code by inspecting the code generated by Kendo Asp.Net MVC helpers.

I don't know if this is a further implementation that didn't exist at the age of the post, but this way looks really the most flexible compared to the other answers that i saw. HTH

Try this:

  1. Add this to your grid read function or any CRUD operation:

    .Read(read => read.Action("ReadCompanyService", "Admin").Data("CompanyServiceFilter"))
    
  2. Add javascript:

    function CompanyServiceFilter()
    {
        return {
            company: $("#ServiceCompany").val()
        }
    } 
    
  3. In your controller:

    public ActionResult ReadCompanyService([DataSourceRequest]DataSourceRequest request, string company)
    {
        var gridList = repository.GetCompanyServiceRateList(company);
        return Json(gridList.ToDataSourceResult(request));
    }
    

Please note, only string type data is allowed to be passed on read, create, update and delete operations.

If you want to pass some param to ajax request, you can use parameterMap configuration on your grid.

This will get passed on to your Ajax request.

parameterMap: function (options, operation) {
    if (operation === "read") {
        var selectedID = $("#SomeElement").val();
        return {ID: selectedID }
    }
    return kendo.stringify(options.models) ;
}

Try this:

.Read(read => read.Action("Controller", "Action")
    .Data(@<text>
        function() {                                            
            return {
                searchModel: DataFunctionName(),
                userName: '#=UserName#'
            }
        }
    </text>)
)

JS function

function DataFunctionName() {
    var searchModel = {
        Active: $("#activityMonitorIsActive").data('kendoDropDownList').value(),
        Login: $("#activityMonitorUsers").data('kendoComboBox').value()
    };
    return searchModel;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top