PDA

View Full Version : set checklist in checkbox when window reopen



y0uzha
13 Jan 2015, 12:52 AM
hi i have a modal window that have grid panel form like this
51493
then, i have check in "c" row. how can i keep that check position when the modal window reopened.
this is my code:

var check = new Ext.selection.CheckboxModel({
checkOnly : true,
});


var grid1 = Ext.create('Ext.grid.Panel', {
title: 'Group Fields',
id:'gridPanel',
selModel: check,
store: Ext.data.StoreManager.lookup('tes'),
columns: [{
text: 'Field',
dataIndex: 'field',
//align: 'center',
flex: 1
}],
viewConfig: {
markDirty: false
},
height: 200,
width: 400
});


pls help. thx.

Jad
13 Jan 2015, 5:52 AM
hi

http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.selection.CheckboxModel-method-selecthi

y0uzha
14 Jan 2015, 1:21 AM
hi jad. thx for your reply but i have try read and try some methods in there. but i still fail. what method i should use for my case.?

Jad
14 Jan 2015, 6:56 AM
Ext.create('Ext.grid.Panel', { renderTo: Ext.getBody(), store: Ext.create('Ext.data.Store', { fields: [{name: 'name'}], data: [ {name: 'jad'}, {name: 'toto'}, {name: 'selected'} ] }), title: 'grid', columns: [{ dataIndex: 'name', text: 'name', flex: 1 }], selModel: Ext.create('Ext.selection.CheckboxModel'), listeners: { afterrender: function (grid) { grid.getSelectionModel().select(2) } } });

y0uzha
15 Jan 2015, 8:11 PM
hi jad. i've try your code but it still doesn't work. when the window reopened, the checkbox was unchecked.

Jad
15 Jan 2015, 11:43 PM
can you show me the code of your window ?

y0uzha
16 Jan 2015, 12:57 AM
i'm sorry i don't know how to import file from local to jsfiddle to make a modal window. because i use 2 file to make it.
maybe this is more simple case. how to set default check in ext.selection.checkbox when loaded.?

u can see my code in here.

http://jsfiddle.net/y0uzha/f73kx37e/1/

how if i want to check the row of gridpanel depends from value of the textfield .?

Jad
16 Jan 2015, 7:28 AM
var datafields = Ext.create('Ext.data.Store', {
storeId:'tes',
fields: ['field'],
data : [
{ "field":"a"},
{ "field":"b"}
]
});

var check = new Ext.selection.CheckboxModel({
checkOnly : true,
listeners: {
change: function(checkbox, value) {

}
}
});


Ext.create('Ext.form.Panel', {
renderTo: "example-grid",
bodyStyle: 'padding: 5px 5px 0 5px;',
items: [
{
xtype: 'textfield',
fieldLabel: 'Group Fields ',
value:'a',
readOnly: true,
inputId: 'group'
}]
});


var grid1 = Ext.create('Ext.grid.Panel', {
title: 'Group Fields',
id:'gridPanel',
selModel: check,
store: Ext.data.StoreManager.lookup('tes'),
columns: [{
text: 'Field',
dataIndex: 'field',
flex: 1
}],
viewConfig: {
markDirty: false
},
listeners: {
viewready: function() {
check.doSelect(grid1.store.data.items[0]);
},
scope: this
},
height: 200,
width: 200
});


Ext.create('Ext.tab.Panel', {
width: 200,
height: 200,
renderTo: "example-grid",
items: [grid1]
});

y0uzha
18 Jan 2015, 8:31 AM
thx it works. but how if i want check it depends the value of textfield. for example, if the value of textfield is A,B. ??

Jad
18 Jan 2015, 11:18 PM
You can use search store's functions like find() or findBy()

y0uzha
1 Feb 2015, 10:44 PM
sorry for my late reply. yeah i've try with function find() like your suggestion and it works. thx for your help :)