让Ext.grid.GridPanel不能选择,即令Ext.grid.CheckboxSelectionModel不能选择,因为GridPanel是要引用CheckboxSelectionModel的。下例是当store里的用户状态不正常(字段memberstatus不为1)的记录行,让它在被选择时提示无法选择,关键在于'beforerowselect'事件,看代码吧

 1 var membersm = new Ext.grid.CheckboxSelectionModel({
2 dataIndex:"memberid"
3 ,listeners:{'beforerowselect': function( SelectionModel, rowIndex, keepExisting,record ) {
4 if(record.data.memberstatus!='1'){ //用户状态不正常
5 Ext.Msg.alert("提示信息","该党员状态为禁用,无法选择!");
6 return false; //不能进行选择
7 }else{
8 return true;
9 }
10 }}
11
12 });
 
————————
PS:文章系转载,开始看了半天,由于本人对ExtJS的无知,导致不知道怎么玩。后来慢慢会了。哈哈。
先得在
<ext:CheckboxSelectionModel Visible="true" ID="UserCheck" runat="server" SelectedRecordID="UserId">
</ext:CheckboxSelectionModel>
 ”
之间,调用“BeforeRowSelect”事件,代码如下:
1 <ext:CheckboxSelectionModel Visible="true" ID="UserCheck" runat="server" SelectedRecordID="UserId">
2 <Listeners>
3 <BeforeRowSelect Fn="MyBeforeRowSelect" />
4 </Listeners>
5 </ext:CheckboxSelectionModel>

然后写个JS方法即可,如下,其中返回false表示此行的CheckboxSelectionModel不允许被选中,返回true,表示允许被选中

1 var MyBeforeRowSelect = function(SelectionModel, rowIndex, keepExisting, record) {
2 //alert("sss" + rowIndex + ",当前UserName的值:" + record.get('UserName') + ",当前ISMY的值:" + record.get('ISMY'));
3 if (record.get('ISMY') == "0") {
4 return false;
5 }
6 else {
7 return true;
8 }
9 }

感概下:nnd,俺需要学的的确够多啊。。

 
 
 
posted on 2011-08-10 21:07  伤寒泪  阅读(5253)  评论(2编辑  收藏  举报