PDA

View Full Version : Values saving in dataview



micky1984
11 Jun 2010, 3:04 AM
I have textboxes and a check box and two radio buttons. Can anyone help me out how i can save these fields value on onchage events: my code is:


xtype: 'form',
id: 'phyexam_show_all_sys_panel' + r.get('id'),
frame: false,
autoScroll: true,
border: false,
items: new Ext.DataView({
store: new Ext.data.JsonStore({
url: 'connect.php',
baseParams: {
moduleId: moduleId,
action: 'doAction',
section_name: 'ALL',
activity: 'getROS'
}, autoLoad: true,
root: 'ALL',
fields: ['section', 'section_item', 'id']
}),
tpl: new Ext.XTemplate('<tpl for=".">', '<div class="ros-wrap-class" title="{section}">', '<div class="ros-textbox-class">', '<span style="font-size:12px">{section_item}</span><br/>', '<input type="text" onkeyup="alert(this.value)">', '</div>', '<div>', '<fieldset class="ros_fieldset">', '<input type="checkbox">', '<span> Current</span><br/>', '<input type="radio" name="{section_item}" id="{id}_1">', '<span> Yes </span>', '<input type="radio" name="{section_item}" id="{id}_2">', '<span> No</span>', '</fieldset>', '</div>', '</div>', '</tpl>'),
listeners: {
click: function (dataView, index, node, e) {}
}, id: 'soap-phyexam-center-rosall' + r.get('id'),
autoHeight: true,
itemSelector: 'div.ros-wrap-class',
emptyText: 'No images to display'
})

i want to save my all values like textfield + checkbox + radio button everythin on onchange.

Please help... Thanks in advance.

swarnendude
11 Jun 2010, 3:58 AM
Onchange of which field?
Do you want to fire onchange event for all the fields?

You can use dataview onClick event :


new Ext.DataView({
onClick: function (e, el) {
console.log(e, el);
}, scope: this
})

grgur
11 Jun 2010, 4:57 AM
please dont spam with your private messages

micky1984
11 Jun 2010, 6:16 AM
No, not on onclick by that code i posted above i see multiple textboxes according to database records.
I want, when i change the values in the textbox then i want to save the fields value.
I think now you got my point.


I need help to saving values of the textfields that is in dataview.

swarnendude
12 Jun 2010, 1:59 AM
Do one thing - put the whole template block inside a div like this:


new Ext.XTemplate('<div id="container"><tpl for=".">', .... Give the textfield inside the template a particular class like:


<input type="text" class="my-textflds"/>Now access the textfields this way :


var txtflds = Ext.get('container').select('input.my-textflds');And for each textfields, create a listener :


Ext.each(txtflds, function(fld){
Ext.get(fld).on('change', function(e){
console.log(Ext.get(fld).getValue());
},this);
}, this);Hope, this will help you.

micky1984
12 Jun 2010, 2:17 AM
Thanks swarnendude for your reply. Where i put this code
var txtflds = Ext.get('container').select('input.my-textflds'); and


Ext.each(txtflds, function(fld){
Ext.get(fld).on('change', function(e){
console.log(Ext.get(fld).getValue());
},this);
}, this);

please let me know.

swarnendude
12 Jun 2010, 2:27 AM
This should work only when those dataview elements are rendered properly. You can try executing them on Store load.

micky1984
12 Jun 2010, 3:00 AM
But the problem is the id goes same <div id="container"> container every time. This is the problem.

swarnendude
12 Jun 2010, 3:02 AM
new Ext.XTemplate('<div id="container"><tpl for=".">', ....

DIV is defined outside tpl. Check again.

micky1984
14 Jun 2010, 2:00 AM
No, This is not working for me.
Give me some other solution.