work in progress: grid (records) field
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3004 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
13d5d43021
commit
3ac67abd37
2 changed files with 13 additions and 2 deletions
|
@ -39,6 +39,8 @@ class Email(schema.TextLine):
|
|||
|
||||
# put field type name and other info in standard field classes.
|
||||
schema.Field.__typeInfo__ = ('textline',)
|
||||
schema.Int.__typeInfo__ = ('number',)
|
||||
schema.Float.__typeInfo__ = ('number',)
|
||||
schema.Choice.__typeInfo__ = ('dropdown',)
|
||||
|
||||
|
||||
|
|
|
@ -78,13 +78,22 @@ class GridFieldInstance(ListFieldInstance):
|
|||
return dict(headers=headers, rows=rows)
|
||||
|
||||
def unmarshall(self, value):
|
||||
value = value.strip()
|
||||
if not value:
|
||||
return []
|
||||
result = []
|
||||
rows = json.loads(value)['items']
|
||||
for row in rows:
|
||||
item = {}
|
||||
empty = True
|
||||
for fi in self.columnFieldInstances:
|
||||
item[fi.name] = fi.unmarshall(row[fi.name])
|
||||
result.append(item)
|
||||
value = fi.unmarshall(row[fi.name])
|
||||
item[fi.name] = value
|
||||
if fi.default is not None:
|
||||
if value != fi.default:
|
||||
empty = False
|
||||
elif value:
|
||||
empty = False
|
||||
if not empty:
|
||||
result.append(item)
|
||||
return result
|
||||
|
|
Loading…
Add table
Reference in a new issue