0

我想在 Telerik().Grid 中调用 Ajax 函数。

这是我的 Telerik().Grid

 @(Html.Telerik().Grid(Model)
        .Name("SiteGrid")
        .Columns(columns =>
        {
            columns.Bound(o => o.PKComID).Width(50);
             columns.Bound(o => o.CompanyName).Width(50);    
//In here I want to add a button and call the Ajax function when click the button   
        })    

          .Pageable(paging => paging.PageSize(15).Style(GridPagerStyles.NextPreviousAndNumeric).Position(GridPagerPosition.Bottom))
                 .Sortable()
    ) 

这是我的 Java 脚本函数

<script type="text/javascript">

    function getCompanyDetails(companyID) {

        $.ajax({

            type: 'POST',
            dataType: 'html',
            url: '@Url.Action("CompanybyID", "Search")',
            data: ({ ComID: companyID }),
            success: function (data) {
                //alert(data);
                $('#companyDetails').html(data);


            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(xhr.status);
                alert(thrownError);
            }
        });

    }
  </script>

如何getCompanyDetails()在网格视图中调用该函数?

4

1 回答 1

0
@(Html.Telerik().Grid(Model)
        .Name("SiteGrid")
        .Columns(columns =>
        {
            columns.Bound(o => o.PKComID).Width(50);
            columns.Bound(o => o.CompanyName).Width(50);      
        })    
           .ClientEvents(events => events.OnComplete("getCompanyDetails"))
          .Pageable(paging => paging.PageSize(15).Style(GridPagerStyles.NextPreviousAndNumeric).Position(GridPagerPosition.Bottom))
                 .Sortable()
    ) 

官方示例: http ://demos.telerik.com/aspnet-mvc/razor/grid/customcolumncommand

于 2013-12-11T20:11:38.550 回答