[#385]add row add delete support for reclinejs
This commit is contained in:
@@ -78,6 +78,8 @@ var createExplorer = function(dataset, state) {
|
|||||||
gridOptions: {
|
gridOptions: {
|
||||||
editable: true,
|
editable: true,
|
||||||
enabledAddRow: true,
|
enabledAddRow: true,
|
||||||
|
enabledDelRow: true,
|
||||||
|
autoEdit: false,
|
||||||
enableCellNavigation: true
|
enableCellNavigation: true
|
||||||
},
|
},
|
||||||
columnsEditor: [
|
columnsEditor: [
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ this.recline.View = this.recline.View || {};
|
|||||||
|
|
||||||
(function($, my) {
|
(function($, my) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add new grid Control to display a new row add menu bouton
|
// Add new grid Control to display a new row add menu bouton
|
||||||
// It display a simple side-bar menu ,for user to add new
|
// It display a simple side-bar menu ,for user to add new
|
||||||
// row to grid
|
// row to grid
|
||||||
@@ -102,10 +99,9 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
this.editor = new my.GridControl()
|
this.editor = new my.GridControl()
|
||||||
this.elSidebar = this.editor.$el
|
this.elSidebar = this.editor.$el
|
||||||
this.listenTo(this.editor.state, 'change', function(){
|
this.listenTo(this.editor.state, 'change', function(){
|
||||||
this.model.records.add({})
|
this.model.records.add(new recline.Model.Record())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
onRecordChanged: function(record) {
|
onRecordChanged: function(record) {
|
||||||
// Ignore if the grid is not yet drawn
|
// Ignore if the grid is not yet drawn
|
||||||
@@ -150,7 +146,9 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
var validator = function(field){
|
var validator = function(field){
|
||||||
return function(value){
|
return function(value){
|
||||||
if(field.type == "date" && isNaN(Date.parse(value))){
|
if(field.type == "date" && isNaN(Date.parse(value))){
|
||||||
return {valid: false, msg: "A date is required , check field field-date-format"};
|
return {
|
||||||
|
valid: false,
|
||||||
|
msg: "A date is required, check field field-date-format"};
|
||||||
}else {
|
}else {
|
||||||
return {valid: true, msg :null }
|
return {valid: true, msg :null }
|
||||||
}
|
}
|
||||||
@@ -230,12 +228,16 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
columns = columns.concat(tempHiddenColumns);
|
columns = columns.concat(tempHiddenColumns);
|
||||||
|
|
||||||
// Transform a model object into a row
|
// Transform a model object into a row
|
||||||
function toRow(m) {
|
function toRow(m) {
|
||||||
var row = {};
|
var row = {};
|
||||||
self.model.fields.each(function(field){
|
self.model.fields.each(function(field){
|
||||||
row[field.id] = m.getFieldValueUnrendered(field);
|
var render = "";
|
||||||
|
//when adding row from slickgrid the field value is undefined
|
||||||
|
if(!_.isUndefined(m.getFieldValueUnrendered(field))){
|
||||||
|
render =m.getFieldValueUnrendered(field)
|
||||||
|
}
|
||||||
|
row[field.id] = render
|
||||||
});
|
});
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user