c#html-空时隐藏剑道网格

c#html-空时隐藏剑道网格,c#,html,kendo-ui,kendo-grid,kendo-asp.net-mvc,C#,Html,Kendo Ui,Kendo Grid,Kendo Asp.net Mvc,我的html代码中有以下剑道网格,如果没有数据,我会试图隐藏它。我对如何做感到困惑,因为我使用的是数据源,而不是通过迭代来添加数据 @(Html.Kendo().Grid<CustomerQuickHistory>() .Name("TransactionDetails") .Columns(cols => { cols.Bound(c => c.Date

我的html代码中有以下剑道网格,如果没有数据,我会试图隐藏它。我对如何做感到困惑,因为我使用的是数据源,而不是通过迭代来添加数据

 @(Html.Kendo().Grid<CustomerQuickHistory>()
                  .Name("TransactionDetails")
                  .Columns(cols => {
                      cols.Bound(c => c.DateOfItem).Format("{0:MM/dd/yyyy}");
                      cols.Bound(c => c.ProductName);
                      cols.Bound(c => c.Price);
                  })
                  .DataSource(ds => ds
                      .Ajax()
                      //.Group(g => g.Add(d => d.CustomerName))
                      .Sort(s => s.Add(ad => ad.DateOfItem).Descending())
                      .Read(r => r.Action("TransactionHistory_Read", "Customers", new { customerId = Model.CustomerId }))
                  )
                  )
@(Html.Kendo().Grid())
.名称(“交易详情”)
.Columns(cols=>{
cols.Bound(c=>c.DateOfItem.Format(“{0:MM/dd/yyyy}”);
cols.Bound(c=>c.ProductName);
cols.Bound(c=>c.Price);
})
.DataSource(ds=>ds
.Ajax()
//.Group(g=>g.Add(d=>d.CustomerName))
.Sort(s=>s.Add(ad=>ad.DateOfItem.Descending())
.Read(r=>r.Action(“TransactionHistory_Read”,“Customers”,new{customerId=Model.customerId}))
)
)

如何使用数据绑定事件处理程序定义、检查绑定的数据源以及显示或隐藏网格

下面是一个类似的示例,但在本例中,当网格为空时,它会显示一条消息

代码示例:

@(Html.Kendo().Grid())
.名称(“网格”)
.列(列=>
{
columns.Bound(p=>p.ProductName).Title(“产品名称”);
列.绑定(p=>p.UnitPrice).标题(“单价”);
columns.Bound(p=>p.UnitsInStock).Title(“库存单位”);
})
.Events(Events=>Events.DataBound(“ongridatabound”))
.DataSource(DataSource=>DataSource
.Ajax()
.Read(Read=>Read.Action(“产品读取”、“网格”))
)
)
函数onGridDataBound(e){
var grid=e.sender;
if(grid.dataSource.total()==0){
//隐藏网格
$(grid.hide();
}
否则{
//显示网格
$(grid.show();
}
}

网格事件都在浏览器中执行,但您可以使用c#think注册。