PDA

View Full Version : Ext.grid.CheckboxSelectionModel and two colums



treblereel
17 May 2010, 3:26 AM
Hi all, if i use CheckboxSelectionModel i see 2 checkbox (width set to 100) colums,and only one colum if width->default(but unchecked) see attachments,
Plz Help



<html>
<head>
<title>grid</title>

<script type="text/javascript" src="<?php echo base_url();?>js/extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>js/extjs/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>js/extjs/resources/css/ext-all.css"></link>

<style type="text/css">
</style>
</head>
<body>
<script type="text/javascript">

var usersGroupsForGrid = new Ext.data.JsonStore({
autoLoad: true,
id: 'usersGroupsForGridId',
url: '<?php echo base_url();?>groups/getGroupsForGrid',
root: 'users',
mode: 'remote',
totalProperty: 'count',
fields: [{ name: 'user_id' }, { name: 'username' },{ name: 'id' }, { name: 'group_id' },{ name: 'group_name' },{name: 'checked'}]

});
usersGroupsForGrid.setDefaultSort('username', 'asc');
usersGroupsForGrid.load({params:{'group_id':'1'}});

var CheckboxSelectionModelUGG = new Ext.grid.CheckboxSelectionModel({

id: 'CheckboxSelectionModelUGGID',
dataIndex:'checked',
singleSelect: false,
width: 100
});

var usersGroupsGrid = new Ext.grid.GridPanel({
store: usersGroupsForGrid,
cm: new Ext.grid.ColumnModel({
defaults: {
width: 120,
sortable: true
},
// selModel: CheckboxSelectionModelUGG,
columns: [
CheckboxSelectionModelUGG,
{ dataIndex: 'id', sortable: true, hidden: true },
{ id: 'usersGroupsGridUN', header: "username", dataIndex: 'username', sortable: true },
{ id: 'usersGroupsGridGN', dataIndex: 'group_id', hidden: true },
{ id: 'usersGroupsGridGNNAME', header: "group_name", dataIndex: 'group_name',sortable: true },


]
}),
// sm: CheckboxSelectionModelUGG,
columnLines: true,
width:460,
height:500,
frame:true,
id: 'usersGroupsGridId',
title: 'Users <--> Deps',
iconCls:'icon-grid',
renderTo: document.body
});




/script>
</body>
</html>



Json:


{"count":7,"users":[{"username":"chani","user_id":"1","group_id":"10","id":"group_10","group_name":"asdasd","checked":"true"},{"username":"admin2","user_id":"7","group_id":"1","id":"group_1","group_name":"default","checked":"true"},{"username":"test2","user_id":"8","group_id":"12","id":"group_12","group_name":"last","checked":"true"},{"username":"lvl","user_id":"10","group_id":"10","id":"group_10","group_name":"asdasd","checked":"true"},{"username":"justone","user_id":"11","group_id":"1","id":"group_1","group_name":"default","checked":"true"},{"username":"nnm","user_id":"13","group_id":"11","id":"group_11","group_name":"next5","checked":"true"},{"username":"\u044b\u0432\u0430\u0432\u044b\u0430\u0444\u044b\u0432","user_id":"16","group_id":"1","id":"group_1","group_name":"default","checked":"true"}]}

Condor
17 May 2010, 3:58 AM
Do you want a CheckboxSelectionModel or a CheckColumn?

A CheckboxSelectionModel doesn't have a dataIndex!

treblereel
17 May 2010, 4:04 AM
hmm, i want grid with checkbox's populated via json. but checked checkbox's i see in 2.png ?

Condor
17 May 2010, 4:13 AM
In that case you should be using an Ext.ux.grid.CheckColumn (from the examples/ux directory).

treblereel
17 May 2010, 4:29 AM
thnx