PDA

View Full Version : Radio Button Instead of Check Box on Data Grid



jackjones2010
11 Jan 2011, 9:51 PM
Good Day everyone, I would like to ask you guys in regards to my problem on datagrid. An array on grid that displays Radio Button instead of Check Boxes. And also I would like to ask you guys on how to save this one to the database, Currently I'm using Firebird v.2.5, But more important on me is on the Design as what I've mentioned, I will deal on the next problem after this one. Thank You Guys, Looking Forward to read all you support.

By the way, here is the Screen shot.

24245

danguba
12 Jan 2011, 12:36 AM
If U only need single selection U can use singleSelect: true

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

danguba
12 Jan 2011, 12:46 AM
And U can check this one
http://www.sencha.com/forum/showthread.php?28070-2.x-Ext.grid.RadioColumn

mond
12 Jan 2011, 5:06 AM
radio Column is great! but i have similar problem with this. how to get the Values of radio each time it is checked.

im having a hard time analyzing this. woohooo!


24253

danguba
12 Jan 2011, 5:55 AM
I'm not sure what R U trying to achieve

mond
12 Jan 2011, 6:26 AM
ok let me rephrase my question.

how to save the selected radio button into database.

im using getselectionmodel() and getselections().

danguba
12 Jan 2011, 7:00 AM
Well that's easy. Just loop through store and get the values you need. For example:

var item = 0;
var data = [];
var currentRecord;
while (grid.store.getAt(item)) {
currentRecord = grid.store.getAt(item);
data.push({
name: currentRecord.data.name,
yesValue: currentRecord.data.yesValue,
...
})
item++;
}assuming that U used

dataIndex: 'yesValue'as a config for Yes column

mond
12 Jan 2011, 7:07 AM
what is the instance of grid? your gridPanel?

danguba
12 Jan 2011, 7:13 AM
yes

danguba
12 Jan 2011, 7:13 AM
what is the instance of grid? your gridPanel?

Yes

mond
12 Jan 2011, 7:14 AM
Thanks dude!!! i really appreciate your help.
i really learn a lot in your codes and tech.

and lastly
how to retrieve the data from the database and set the values that will match in the db.

danguba
12 Jan 2011, 7:21 AM
Thanks dude!!! i really appreciate your help.

Dont metion it. Im glad I was able to help.



how to retrieve the data from the database and set the values that will match in the db.

I'm sorry but I'll have to let U down on this one. I'm strictly GUI developer so DB is out of my expertize

mond
12 Jan 2011, 7:25 AM
ah i see. but can you give any example.
even a simple dummy data stores.

danguba
12 Jan 2011, 7:32 AM
I'm not sure what do U need. You can check different ways to load grid store at http://dev.sencha.com/deploy/dev/examples/

mond
12 Jan 2011, 7:49 AM
last sir. theres have a problem with pagination. when i move to the next page. the selections in the previous are gone the radio button.

danguba
12 Jan 2011, 8:45 AM
Can U post a code snippet of U'r grid configuration?

mond
12 Jan 2011, 8:49 AM
code:



var dbGrid = Ext.extend(Ext.grid.GridPanel,{
store : _store,
id : 'itemlist',
border : false,
align : 'center',
height :285,
width :600,
viewConfig: {
forceFit:true,
enableRowBody:true,
},
//columns : columns,
renderTo: dbGrid,
cm: new Ext.grid.ColumnModel({
columns: [new Ext.grid.CheckboxSelectionModel(),
{header : 'Items', dataIndex : 'itemdesc', id:'itemdesc', align:'left',width:70}].concat(answers),
}),
autoExpandColumn : 'itemdesc',
plugins : [new Ext.ux.plugins.CheckBoxMemory()].concat(answers),
selModel : sm,
i installed the checkbox memory plugin. but this is not also working with radio. if im not mistaken.

danguba
12 Jan 2011, 8:59 AM
And what about the store? Is your pagination done on server or on client?

mond
12 Jan 2011, 9:07 AM
client side.

my store:



listitems = new Ext.data.Store({
reader : new Ext.data.ArrayReader({},[
{name:'itemdesc'},
{name:'Y'},
])
})

store = new Ext.data.ArrayStore({
fields : [
{name:'itemdesc'},
{name:'Y'},
]
})

danguba
13 Jan 2011, 12:21 AM
I'm not sure why radio buttons on previous page get deselected. If U can make some demo page we could debug it together.

mond
18 Jan 2011, 3:16 AM
hi dude, how to change the result to array [[1],[2]]?

danguba
18 Jan 2011, 3:38 AM
Just do:

var item = 0;
var data = [];
var currentRecord;
while (grid.store.getAt(item)) {
currentRecord = grid.store.getAt(item);
data.push(currentRecord.data.yesValue)
item++;
}