在devexpress网格的所有页面中选择的行数计数
我有一个在asp.net和c.net应用程序中具有多个页面的devexpress网格。我只想在网格的所有页面中进行2次选择。如果我在所有页面中选择了两行以上,它将显示一个警报在devexpress网格的所有页面中选择的行数计数,devexpress,Devexpress,我有一个在asp.net和c.net应用程序中具有多个页面的devexpress网格。我只想在网格的所有页面中进行2次选择。如果我在所有页面中选择了两行以上,它将显示一个警报 如何获取在devexpress网格的所有页面中选择的行数?我们建议您使用以下方法: 1使用CustomJSProperties事件将当前所选记录的信息从服务器端传递到客户端。 2使用ASPxGridView的客户端初始化和SelectionChanged事件来管理选择。代码如下: //CS //JS protected
如何获取在devexpress网格的所有页面中选择的行数?我们建议您使用以下方法: 1使用CustomJSProperties事件将当前所选记录的信息从服务器端传递到客户端。 2使用ASPxGridView的客户端初始化和SelectionChanged事件来管理选择。代码如下: //CS //JS
protected void grid_CustomJSProperties(object sender, ASPxGridViewClientJSPropertiesEventArgs e) {
e.Properties["cpSelectionCount"] = (sender as ASPxGridView).Selection.Count.ToString();
}
<script type="text/javascript">
var selectedCount = 0;
</script>
<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" KeyFieldName="CategoryID" OnCustomJSProperties="grid_CustomJSProperties" DataSourceID="AccessDataSource1">
<ClientSideEvents SelectionChanged="function(s,e) {
if(e.isChangedOnServer)
return;
if(e.isSelected)
selectedCount += 1;
else
selectedCount -= 1;
if(e.isSelected && selectedCount > 2) {
alert('You selected more than 2 records');
s.UnselectRowOnPage(e.visibleIndex);
return;
}
}"
Init="function(s,e) {
selectedCount = parseInt(s.cpSelectionCount);
}"/>
<Columns>
...
</Columns>
</dx:ASPxGridView>