简体   繁体   中英

How to pass additional data with ajax binding in kendo ui grid in MVC,cshtml?

I`m using a Kendo UI grid. In here I need to pass additional data to the backend. I used this method to it. But it giving an error of ".Data() does not contain a definition for Data"

This is my cshtml code.

                @(Html.Kendo().Grid<CrowdlogisticsWebMVC.Models.ContactMediumModel>()
                    .Name("gridAddress")
                    .Columns(columns =>
                    {
                        columns.Bound(p => p.PartyID).Title("").Width(30);
                        columns.Bound(p => p.AddressLine1).Width(150);
                        columns.Bound(p => p.AddressLine2).Width(150);
                        columns.Bound(p => p.City).Width(150);
                        columns.Bound(p => p.Country).Width(150);
                    })                         
                    .Filterable()
                    .DataSource(dataSource => dataSource
                        .Ajax()
                         .Read(read => read.Action("GetAddresses", "Party"))
                          .Data("productsReadData")
                     )
               )


<script type="text/javascript">

    function productsReadData() {
        return {
            firstName: "John",
            lastName: "Doe"
        };
    }

</script >

Little mistake - Data() should be after Action() not after Read() (inside Read) like this:

.DataSource(dataSource => dataSource
                    .Ajax()
                    .Read(read => read.Action("GetAddresses", "Party").Data("productsReadData"))                         
           )

Regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM