Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何对局部视图telerik网格进行排序?_C#_Asp.net Mvc_Telerik - Fatal编程技术网

C# 如何对局部视图telerik网格进行排序?

C# 如何对局部视图telerik网格进行排序?,c#,asp.net-mvc,telerik,C#,Asp.net Mvc,Telerik,我正在使用telerik网格和mvc 我在局部视图中创建了telerik网格。我的telerik网格排序不起作用 这是我的控制器 public ActionResult Index() { var query = from c in db.tblCompanies select c; return View(query.ToList()); } public ActionResult SearchCompany(string CompanyNam

我正在使用telerik网格和mvc

我在局部视图中创建了telerik网格。我的telerik网格排序不起作用

这是我的控制器

public ActionResult Index()
{
    var query = from c in db.tblCompanies
                select c;
    return View(query.ToList());
}

public ActionResult SearchCompany(string CompanyName)
{
    var query = from c in db.tblCompanies
                select c;
    if (CompanyName != "")
    {
        query = query.Where(s => s.CompanyName.Contains(CompanyName));
    }

    return PartialView("_comList", query);
}
这是我的看法

script type="text/javascript">

    function SearchCompany() {
        var CompanyName = document.getElementById('txtCompanyName').value;
        $.ajax({

            type: 'POST',
            dataType: 'html',
            url: '@Url.Action("SearchCompany", "Company")',
            data: ({ CompanyName: CompanyName }),
            success: function (data) {
                //alert(data);
                $('#CompList').html(data);

            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(xhr.status);
                alert(thrownError);
            }
        });
    }
</script>

<table>
  <tr>
    <td>Company Name:</td>
    <td>@Html.TextBox("txtCompanyName")</td>
  </tr>
  <tr>
    <td></td>
    <td><input type="button" value="Search" onclick="SearchCompany();" /></td>
  </tr>
</table>      

<div id="CompList">
  @Html.Partial("_comList", CompanyList)
</div>
scripttype=“text/javascript”>
功能搜索公司(){
var CompanyName=document.getElementById('txtCompanyName').value;
$.ajax({
键入:“POST”,
数据类型:“html”,
url:'@url.Action(“搜索公司”、“公司”),
数据:({CompanyName:CompanyName}),
成功:功能(数据){
//警报(数据);
$('#CompList').html(数据);
},
错误:函数(xhr、ajaxOptions、thrownError){
警报(xhr.状态);
警报(thrownError);
}
});
}
公司名称:
@Html.TextBox(“txtCompanyName”)
@Html.Partial(“\u comList”,公司列表)
这是我的部分观点

@(Html.Telerik().Grid(Model)
        .Name("CompanyGrid")


        .Columns(columns =>
        {
            columns.Bound(o => o.CompanyId).Width(5).Title("ID"); ;
            columns.Bound(o => o.CompanyName).Width(50);
            columns.Bound(o => o.CompanyAddress).Width(60).Title("Address");           
            columns.Bound(o => o.Phone).Width(20);
            columns.Bound(x => x.PKComID)
          .Width(30)
              .Template(x => Html.ActionLink("Edit", "Edit", new { id = x.PKComID }))
           .ClientTemplate("<a href=\"Edit/<#= Id #>\"> EDIT </a>")
           .Title("Edit").Sortable(false);

            columns.Bound(x => x.PKComID)
        .Width(30)
            .Template(x => Html.ActionLink("Delete", "Delete", new { id = x.PKComID }, new { onclick = "return confirm('Are you sure you wish to delete this Company?');" }))
         .ClientTemplate("<a href=\"Edit/<#= Id #>\"> EDIT </a>")
         .Title("Delete").Sortable(false);

        })

          .Pageable(paging => paging.PageSize(15).Style(GridPagerStyles.NextPreviousAndNumeric).Position(GridPagerPosition.Bottom))
                 .Sortable()
    ) 
@(Html.Telerik().Grid(模型)
.名称(“CompanyGrid”)
.列(列=>
{
columns.Bound(o=>o.CompanyId).Width(5.Title(“ID”);
columns.Bound(o=>o.CompanyName).Width(50);
columns.Bound(o=>o.CompanyAddress).Width(60).Title(“地址”);
columns.Bound(o=>o.Phone).Width(20);
columns.Bound(x=>x.PKComID)
.宽度(30)
.Template(x=>Html.ActionLink(“编辑”,“编辑”,新的{id=x.PKComID}))
.ClientTemplate(“”)
.标题(“编辑”)。可排序(假);
columns.Bound(x=>x.PKComID)
.宽度(30)
.Template(x=>Html.ActionLink(“删除”,“删除”,新建{id=x.PKComID},新建{onclick=“返回确认('是否确实要删除此公司?');“}))
.ClientTemplate(“”)
.标题(“删除”)。可排序(假);
})
.Pageable(paging=>paging.PageSize(15).Style(GridPagerStyles.NextPreviousAndNumeric).Position(GridPagerPosition.Bottom))
.Sortable()
) 
我的代码有什么问题。。排序不起作用
请帮助我。

确保您正确执行了演示中的所有步骤。

为什么不直接与Telerik支持部门联系?