jaimi
|
 |
« Reply #2 on: September 06, 2012, 11:56:07 PM » |
|
Thank you for the answer.
I worked through the tutorial datagrid12 where a formatter is defined like this: <script> var products = [ {productid:'FI-SW-01',name:'Koi'}, {productid:'K9-DL-01',name:'Dalmation'}, {productid:'RP-SN-01',name:'Rattlesnake'}, {productid:'RP-LI-02',name:'Iguana'}, {productid:'FL-DSH-01',name:'Manx'}, {productid:'FL-DLH-02',name:'Persian'}, {productid:'AV-CB-01',name:'Amazon Parrot'} ]; $(function(){ $('#tt').datagrid({ title:'Editable DataGrid', iconCls:'icon-edit', width:660, height:250, singleSelect:true, idField:'itemid', url:'datagrid_data.json', columns:[[ {field:'itemid',title:'Item ID',width:60}, {field:'productid',title:'Product',width:100, formatter:function(value){ for(var i=0; i<products.length; i++){ if (products.productid == value) return products.name; } return value; }, editor:{ type:'combobox', options:{ valueField:'productid', textField:'name', data:products, required:true } ... I would like to implement a similar functionality. My data loaded into the combobox comes not from a variable but from a url:json.php. How to define the formatter function in this case? And in additon how do I have to define the formatter and editor as javascript functions when I don't want to write them directly into the markup. example: Instead of: <th field="vrl_role" width="100" sortable="true" editor="{type:\'combobox\',options:{valueField:\'productid\', textField:\'name\', data:products, required:true}}">Rolle</th>
I want to implement like this: <th field="vrl_role" width="100" sortable="true" editor="myEditor">Rolle</th>
|