开发者

Check all checkbox in gridpanel in extjs

I would like to check all of the checkbox 开发者_高级运维made by Ext.grid.CheckColumn in a gridpanel, may I know if there is any easy way to do this? I have try to add class to the checkbox(Ext.grid.CheckColumn) but it seem not work.

Thanks very much!


If you're rendering a store field as a checbox column, you have to set that field to true for all the records in the store.

store.each(function(rec){ rec.set('field', true) })

Never try to change a grid cell's value directly, always change it via the store's corresponding record.

Update: if you have many records, use something like this:

store.suspendEvents(); // avoid view update after each row
store.each(function(rec){ rec.set('field', true) })
store.resumeEvents();
grid.getView().refresh();


Ext.grid.CheckboxSelectionModel provides a selectAll() method, if this is what you're looking for.

http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.CheckboxSelectionModel

Can you show us some codes? I presume CheckColumn is something that you created?


<script language="javascript" type="text/javascript">
 var SelectAll = function (value) {
        Store1.data.each(function (record) {
            record.set('IsSelected', value); 
        });
    };
</script>

<ext:Button ID="btnSelectAll" runat="server" Text="Select All" >
      <Listeners>
             <Click Handler="SelectAll(true);" />
      </Listeners>
</ext:Button>

NB: Store1 is the name of the store and IsSelected is the field name as specified in the JsonReader reader

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜