Skip to content

Commit

Permalink
Release: v1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tabalinas committed Dec 9, 2015
1 parent 039c7d3 commit cbb80c2
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsgrid",
"version": "1.3.0",
"version": "1.3.1",
"main": [
"dist/jsgrid.js",
"dist/jsgrid.css",
Expand Down
2 changes: 1 addition & 1 deletion dist/jsgrid-theme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jsgrid-theme.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jsgrid.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* jsGrid v1.3.0 (http://js-grid.com)
* jsGrid v1.3.1 (http://js-grid.com)
* (c) 2015 Artem Tabalin
* Licensed under MIT (https://github.com/tabalinas/jsgrid/blob/master/LICENSE)
*/
Expand Down
54 changes: 44 additions & 10 deletions dist/jsgrid.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* jsGrid v1.3.0 (http://js-grid.com)
* jsGrid v1.3.1 (http://js-grid.com)
* (c) 2015 Artem Tabalin
* Licensed under MIT (https://github.com/tabalinas/jsgrid/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -614,7 +614,7 @@

_createCell: function(item, field) {
var $result;
var fieldValue = item[field.name];
var fieldValue = this._getItemFieldValue(item, field);

if($.isFunction(field.cellRenderer)) {
$result = $(field.cellRenderer(fieldValue, item));
Expand All @@ -630,6 +630,38 @@
return $result;
},

_getItemFieldValue: function(item, field) {
var props = field.name.split('.');
var result = item[props.shift()];

while(result && props.length) {
result = result[props.shift()];
}

return result;
},

_setItemFieldValue: function(item, field, value) {
var props = field.name.split('.');
var current = item;
var prop = props[0];

while(current && props.length > 1) {
item = current;
prop = props.shift();
current = item[prop];
}

if(!current) {
while(props.length) {
item = item[prop] = {};
prop = props.shift();
}
}

item[prop] = value;
},

sort: function(field, order) {
if($.isPlainObject(field)) {
order = field.order;
Expand Down Expand Up @@ -997,7 +1029,7 @@
var result = {};
this._eachField(function(field) {
if(field.filtering) {
result[field.name] = field.filterValue();
this._setItemFieldValue(result, field, field.filterValue());
}
});
return result;
Expand Down Expand Up @@ -1049,7 +1081,7 @@
var result = {};
this._eachField(function(field) {
if(field.inserting) {
result[field.name] = field.insertValue();
this._setItemFieldValue(result, field, field.insertValue());
}
});
return result;
Expand Down Expand Up @@ -1103,9 +1135,11 @@
var $result = $("<tr>").addClass(this.editRowClass);

this._eachField(function(field) {
var fieldValue = this._getItemFieldValue(item, field);

$("<td>").addClass(field.editcss || field.css)
.appendTo($result)
.append(field.editTemplate ? field.editTemplate(item[field.name], item) : "")
.append(field.editTemplate ? field.editTemplate(fieldValue, item) : "")
.width(field.width || "auto");
});

Expand All @@ -1126,9 +1160,9 @@
_updateRow: function($updatingRow, editedItem) {
var updatingItem = $updatingRow.data(JSGRID_ROW_DATA_KEY),
updatingItemIndex = this._itemIndex(updatingItem),
previousItem = $.extend({}, updatingItem);
previousItem = $.extend(true, {}, updatingItem);

$.extend(updatingItem, editedItem);
$.extend(true, updatingItem, editedItem);

var args = this._callEventHandler(this.onItemUpdating, {
row: $updatingRow,
Expand Down Expand Up @@ -1167,7 +1201,7 @@
var result = {};
this._eachField(function(field) {
if(field.editing) {
result[field.name] = field.editValue();
this._setItemFieldValue(result, field, field.editValue());
}
});
return result;
Expand Down Expand Up @@ -1515,7 +1549,7 @@

Field.prototype = {
name: "",
title: "",
title: null,
css: "",
align: "",
width: 100,
Expand All @@ -1528,7 +1562,7 @@
sorter: "string", // name of SortStrategy or function to compare elements

headerTemplate: function() {
return this.title || this.name;
return (this.title === undefined || this.title === null) ? this.name : this.title;
},

itemTemplate: function(value, item) {
Expand Down
2 changes: 1 addition & 1 deletion dist/jsgrid.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/jsgrid.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsgrid",
"version": "1.3.0",
"version": "1.3.1",
"description": "Lightweight data grid jQuery plugin. It supports basic grid operations like inserting, filtering, editing, deleting, paging and sorting. Although jsGrid is tunable and allows to customize appearance and components.",
"keywords": [
"grid",
Expand Down

0 comments on commit cbb80c2

Please sign in to comment.