PDA

View Full Version : Grid as Form Field



drpepper
19 Mar 2009, 2:49 AM
Hi all,

i need some hints how to pu t a grid into a form panel, which is filled with the xmldata loaded by the form. how can i add the grid content to the values of the form on submit?

the idea is to drag items from a tree into the grid and submit the "chosen" items...

i am getting nearly mad, i did not yet found any advice on the web how to connect data storage and grid with the form...

another problem is that form fields, which are defined after the grid element are not rendered and the panel looks weird finally....

any suggestions?

jsakalos
19 Mar 2009, 3:00 AM
As to layout, you can see http://examples.extjs.eu/?ex=treeinform, just replace tree with grid. Additionally, you need to supply getValue function for the grid.

drpepper
19 Mar 2009, 3:49 AM
It is quite easy to add a tree into a form, but how can i add a grid into my form which is filled with data which comes from the xml the form loads?

my xml content looks like this:


<?xml version="1.0" encoding="UTF-8"?>
<ajax success="1">
<product>
<id>2</id>
<name>Testprodukt</name>
<admin_user_id>0</admin_user_id>
<admin_user_name></admin_user_name>
<create_date>2009-03-12 11:23:55</create_date>
<publish_date></publish_date>
<expire_date></expire_date>
<live>1</live>
<short_desc>test</short_desc>
<note>dwdqwdqw</note>
<manufacturer_id>1</manufacturer_id>
<manufacturer_name>test-m</manufacturer_name>
<manufacturer_sku>1234</manufacturer_sku>
<sku>tp-dt-2321</sku>
<categories>
<category>
<id>3</id>
<unqualified_path>/Film/Camera Equipment/Camcorder</unqualified_path>
</category><category>
<id>4</id>
<unqualified_path>/Film/Camera Equipment/System Cameras</unqualified_path>
</category> </categories>
</product></ajax>
(could have been formatted a bit better, i know)

I want to have a row in the grid for each <category>... it is quite difficult for me to understand how to add the data to the storage...

drpepper
25 Mar 2009, 1:57 AM
no one who might help?

jsakalos
25 Mar 2009, 2:32 AM
Loading the grid with xml data and placing it to a form are two different tasks. The best source of info on loading is http://extjs.com/deploy/dev/examples/grid/edit-grid.html and http://extjs.com/learn/Ext_FAQ_Grid.

For having the grid in a form you need to write setValue and getValue functions.

Grid in form is pretty much similar to Combo in form.

Mjollnir26
26 Mar 2009, 7:56 AM
Had the same Problem (injecting Grid as Form-Field).
Based on Saki's Example i defined my Grid with the following Options and now it works perfectly:



fieldLabel: 'Angebote',
isFormField: true,

getName: function()
{
return 'existingOffers';
},

dataIndex: 'existingOffers',

getValue: function()
{
return true;
},

setValue: function(v)
{
},