def add_row(self): """Add a new row.""" # get columns and rows columns = self.listColumns() rows = self._annotations.get("rows") # prepare new row row = dict() row["DT_RowId"] = len(rows) # add an incremental id to new row for column in columns: row[column["id"]] = _("click here to enter data") # save new row rows.append(row) self._annotations._p_changed = True
'collective.table', PersistentMapping() ) return mapping.get('source_name', self.defaultSourceName) security.declarePrivate('getSource') def getSource(self, instance): return component.getMultiAdapter( (self, instance), ISource, name=self.getSourceName(instance)) # We are not a field in the usual manner, so we need to override some # things to clean things up security.declarePrivate('setStorage') def setStorage(self, instance, storage): raise ObjectFieldException("Not supported, \ use field.setSourceName instead") security.declarePrivate('getStorage') def getStorage(self, instance=None): return self.getSource(instance) registerWidget(DataTableWidget, title=_('Data Table'), description=_('Renders the complex data table and manage it\'s ' 'configuration'), used_for=('collective.table.field_widget.DataTableField',) ) registerField(DataTableField, title=_('Data Table'), description=_('Complex data table with flexible sources'))
"""The Table content-type.""" from Products.ATContentTypes.content import document from Products.Archetypes import atapi from collective.table import MessageFactory as _ from collective.table.config import PROJECTNAME from collective.table.field_widget import DataTableField from collective.table.field_widget import DataTableWidget TableSchema = document.ATDocumentSchema.copy() + atapi.Schema(( DataTableField('table', languageIndependent=False, widget=DataTableWidget( label=_(u'label_table', u'Data table'), description=u'', ), ), )) TableSchema.moveField('table', before='text') TableSchema['presentation'].widget.condition = 'python:False' TableSchema['tableContents'].widget.condition = 'python:False' class Table(document.ATDocumentBase): schema = TableSchema document.registerATCT(Table, PROJECTNAME)
def source(self): assert self.sourceName is not None, ( _('Configuration form should set the sourceName attribute')) field = self.context.Schema()[self.fieldName] return component.getMultiAdapter( (field, self.context), ISource, name=self.sourceName)