This commit is contained in:
Samuel Georges 2015-01-03 12:06:12 +11:00
parent 7dd147a62a
commit 04c6fdc7f3
1 changed files with 9 additions and 6 deletions

View File

@ -25,7 +25,7 @@
if (dataString === null || dataString === undefined)
throw new Error('The required data-data attribute is not found on the table control element.')
this.data = JSON.parse(dataString)
};
@ -71,11 +71,10 @@
Client.prototype.createRecord = function(recordData, placement, relativeToKey, offset, count, onSuccess) {
if (placement === 'bottom') {
// Add record to the bottom of the dataset
this.data.push(recordData)
} else if (placement == 'above' || placement == 'below') {
}
else if (placement == 'above' || placement == 'below') {
// Add record above or below the passed record key
var recordIndex = this.getIndexOfKey(relativeToKey)
if (placement == 'below')
recordIndex ++
@ -98,8 +97,10 @@
if (recordIndex !== -1) {
recordData[this.tableObj.options.keyColumn] = key
this.data[recordIndex] = recordData
} else
}
else {
throw new Error('Record with they key '+key+ ' is not found in the data set')
}
}
/*
@ -124,8 +125,10 @@
this.data.push(newRecordData)
this.getRecords(offset, count, onSuccess)
} else
}
else {
throw new Error('Record with they key '+key+ ' is not found in the data set')
}
}
Client.prototype.getIndexOfKey = function(key) {