[#384,slickgrid][s]: slickgrid sets editor type automatically from field type.
* multiview demo now has editing turned on * [license][xs]: update to 2011-2014.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2011 Max Ogden & Contributors
|
Copyright (c) 2011-2014 Max Ogden, Rufus Pollock and Contributors
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|||||||
@@ -73,7 +73,18 @@ var createExplorer = function(dataset, state) {
|
|||||||
id: 'grid',
|
id: 'grid',
|
||||||
label: 'Grid',
|
label: 'Grid',
|
||||||
view: new recline.View.SlickGrid({
|
view: new recline.View.SlickGrid({
|
||||||
model: dataset
|
model: dataset,
|
||||||
|
state: {
|
||||||
|
gridOptions: {
|
||||||
|
editable: true,
|
||||||
|
enabledAddRow: true,
|
||||||
|
enableCellNavigation: true
|
||||||
|
},
|
||||||
|
columnsEditor: [
|
||||||
|
{ column: 'date', editor: Slick.Editors.Date },
|
||||||
|
{ column: 'title', editor: Slick.Editors.Text }
|
||||||
|
]
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -81,6 +92,7 @@ var createExplorer = function(dataset, state) {
|
|||||||
label: 'Graph',
|
label: 'Graph',
|
||||||
view: new recline.View.Graph({
|
view: new recline.View.Graph({
|
||||||
model: dataset
|
model: dataset
|
||||||
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,11 @@ this.recline.View = this.recline.View || {};
|
|||||||
// model: dataset,
|
// model: dataset,
|
||||||
// el: $el,
|
// el: $el,
|
||||||
// state: {
|
// state: {
|
||||||
// gridOptions: {editable: true},
|
// gridOptions: {
|
||||||
|
// editable: true,
|
||||||
|
// enableAddRows: true
|
||||||
|
// ...
|
||||||
|
// },
|
||||||
// columnsEditor: [
|
// columnsEditor: [
|
||||||
// {column: 'date', editor: Slick.Editors.Date },
|
// {column: 'date', editor: Slick.Editors.Date },
|
||||||
// {column: 'title', editor: Slick.Editors.Text}
|
// {column: 'title', editor: Slick.Editors.Text}
|
||||||
@@ -113,6 +117,24 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
var editInfo = _.find(self.state.get('columnsEditor'),function(c){return c.column === field.id;});
|
var editInfo = _.find(self.state.get('columnsEditor'),function(c){return c.column === field.id;});
|
||||||
if (editInfo){
|
if (editInfo){
|
||||||
column.editor = editInfo.editor;
|
column.editor = editInfo.editor;
|
||||||
|
} else {
|
||||||
|
// guess editor type
|
||||||
|
var typeToEditorMap = {
|
||||||
|
'string': Slick.Editors.LongText,
|
||||||
|
'integer': Slick.Editors.IntegerEditor,
|
||||||
|
'number': Slick.Editors.Text,
|
||||||
|
// TODO: need a way to ensure we format date in the right way
|
||||||
|
// Plus what if dates are in distant past or future ... (?)
|
||||||
|
// 'date': Slick.Editors.DateEditor,
|
||||||
|
'date': Slick.Editors.Text,
|
||||||
|
'boolean': Slick.Editors.YesNoSelectEditor
|
||||||
|
// TODO: (?) percent ...
|
||||||
|
};
|
||||||
|
if (field.type in typeToEditorMap) {
|
||||||
|
column.editor = typeToEditorMap[field.type]
|
||||||
|
} else {
|
||||||
|
column.editor = Slick.Editors.LongText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
columns.push(column);
|
columns.push(column);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user