prepare use of grid field
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3009 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
		
							parent
							
								
									3ac67abd37
								
							
						
					
					
						commit
						16a3212f7a
					
				
					 2 changed files with 38 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -23,9 +23,10 @@ $Id$
 | 
			
		|||
"""
 | 
			
		||||
 | 
			
		||||
from zope import component
 | 
			
		||||
from zope.interface import implements
 | 
			
		||||
from zope.cachedescriptors.property import Lazy
 | 
			
		||||
from zope.component import adapts
 | 
			
		||||
from zope.interface import implements
 | 
			
		||||
from zope.app.pagetemplate import ViewPageTemplateFile
 | 
			
		||||
from zope.cachedescriptors.property import Lazy
 | 
			
		||||
import zope.schema
 | 
			
		||||
 | 
			
		||||
from cybertools.composer.schema.factory import createField
 | 
			
		||||
| 
						 | 
				
			
			@ -36,6 +37,9 @@ from cybertools.util.format import toStr, toUnicode
 | 
			
		|||
from cybertools.util import json
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
grid_macros = ViewPageTemplateFile('grid_macros.pt')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GridFieldInstance(ListFieldInstance):
 | 
			
		||||
 | 
			
		||||
    @Lazy
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,21 +6,37 @@
 | 
			
		|||
<metal:input define-macro="input_grid"
 | 
			
		||||
             tal:define="fieldInstance python: field.getFieldInstance(view.instance);
 | 
			
		||||
                         columns fieldInstance/columnTypes">
 | 
			
		||||
 | 
			
		||||
    <span dojoType="dojo.data.ItemFileWriteStore"
 | 
			
		||||
          tal:attributes="jsId string:store_$name;
 | 
			
		||||
                          data data/?name"/>
 | 
			
		||||
 | 
			
		||||
    <table dojoType="dojox.grid.DataGrid"
 | 
			
		||||
           style="width: 35em; height: 15em"
 | 
			
		||||
           tal:attributes="name name; id name;
 | 
			
		||||
    <script type="text/javascript" language="JavaScript"
 | 
			
		||||
            tal:content="string:
 | 
			
		||||
                data_$name = dojo.fromJson('${data/?name}');
 | 
			
		||||
                store_$name = new dojo.data.ItemFileWriteStore({data: data_$name});
 | 
			
		||||
                store_$name._saveEverything = function(ccb, ecb, data) {
 | 
			
		||||
                        dojo.byId('$name').value = data;
 | 
			
		||||
                    };
 | 
			
		||||
                dojo.connect(dojo.byId('editForm'), 'onsubmit', function(evt) {
 | 
			
		||||
                        dijit.byId('grid_$name').edit.apply();
 | 
			
		||||
                        store_$name.save();
 | 
			
		||||
                    });">
 | 
			
		||||
    </script>
 | 
			
		||||
    <textarea rows="3" style="display: none"
 | 
			
		||||
              tal:attributes="name name; id name">
 | 
			
		||||
    </textarea>
 | 
			
		||||
    <table dojoType="dojox.grid.DataGrid" query="{name: '*'}"
 | 
			
		||||
           style="width: 100%; height: 12em"
 | 
			
		||||
           singleClickEdit="true"
 | 
			
		||||
           tal:attributes="id string:grid_$name;
 | 
			
		||||
                           store string:store_$name">
 | 
			
		||||
      <thead>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <tal:header repeat="column columns">
 | 
			
		||||
           <th tal:attributes="field column/name"
 | 
			
		||||
            <th width="auto" editable="true"
 | 
			
		||||
                tal:attributes="field column/name"
 | 
			
		||||
                tal:content="column/title">Column Title</th>
 | 
			
		||||
          </tal:header>
 | 
			
		||||
       </tr></thead></table>
 | 
			
		||||
 | 
			
		||||
        </tr></thead>
 | 
			
		||||
    </table>
 | 
			
		||||
</metal:input>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
		Loading…
	
	Add table
		
		Reference in a new issue