Skip to content

Commit

Permalink
fixed child order in datagrid (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Moosbrugger authored and danrot committed Jul 14, 2016
1 parent 333f4e8 commit 69a184b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG for husky

* 0.21.1 (2016-07-11)
* HOTFIX #688 fixed child order in datagrid
* HOTFIX #670 workaround for ie dorpdown issue
* HOTFIX #679 Globalize: Fixed loading correct file when culture name includes country

Expand Down
26 changes: 24 additions & 2 deletions dist/husky.js
Original file line number Diff line number Diff line change
Expand Up @@ -30926,6 +30926,9 @@ define('husky_components/datagrid/decorators/table-view',[],function() {

record.id = (!!record[this.keys.id]) ? record[this.keys.id] : constants.newRecordId;
this.sandbox.dom.data($row, 'id', record.id);
if (!!record.parent) {
this.sandbox.dom.data($row, 'parent', record.parent);
}

// render the parents before rendering the children
if (hasParent) {
Expand Down Expand Up @@ -30986,13 +30989,32 @@ define('husky_components/datagrid/decorators/table-view',[],function() {
this.table.rows[record.parent].childrenExpanded = true;
this.changeChildrenToggleIcon(record.parent, true);
}
this.sandbox.dom.after($parentElement, this.table.rows[record.id].$el);
// else just append or prepend it
// insert the row after the last child element of the parent, or directly after the parent
// if no such child exists
this.sandbox.dom.after(this.getLastChildElementOfParent($parentElement) || $parentElement,
this.table.rows[record.id].$el);
} else {
insertMethod(this.table.$body, this.table.rows[record.id].$el);
}
},

/**
* Given a parent element the method returns the last child element. If no child element
* exsits null is returned
* @param $parent {Object} the valid parent element
* @returns {Object} the last child element or null
*/
getLastChildElementOfParent: function($parent) {
var $children = $parent.siblings().filter(function() {
return $(this).data('parent') === $parent.data('id');
});
if ($children.length > 0) {
return $children.last();
}

return null;
},

/**
* Manipulates a row of a rendered after it has been rendered. For examples checks the checkbox or focuses an input
* @param record {Object} the data of the record
Expand Down
2 changes: 1 addition & 1 deletion dist/husky.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/husky.min.js

Large diffs are not rendered by default.

28 changes: 26 additions & 2 deletions husky_components/datagrid/decorators/table-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,9 @@ define(function() {

record.id = (!!record[this.keys.id]) ? record[this.keys.id] : constants.newRecordId;
this.sandbox.dom.data($row, 'id', record.id);
if (!!record.parent) {
this.sandbox.dom.data($row, 'parent', record.parent);
}

// render the parents before rendering the children
if (hasParent) {
Expand Down Expand Up @@ -624,13 +627,34 @@ define(function() {
this.table.rows[record.parent].childrenExpanded = true;
this.changeChildrenToggleIcon(record.parent, true);
}
this.sandbox.dom.after($parentElement, this.table.rows[record.id].$el);
// else just append or prepend it
// insert the row after the last child element of the parent, or directly after the parent
// if no such child exists
this.sandbox.dom.after(
this.getLastChildElementOfParent($parentElement) || $parentElement,
this.table.rows[record.id].$el
);
} else {
insertMethod(this.table.$body, this.table.rows[record.id].$el);
}
},

/**
* Given a parent element the method returns the last child element. If no child element
* exsits null is returned
* @param $parent {Object} the valid parent element
* @returns {Object} the last child element or null
*/
getLastChildElementOfParent: function($parent) {
var $children = $parent.siblings().filter(function() {
return $(this).data('parent') === $parent.data('id');
});
if ($children.length > 0) {
return $children.last();
}

return null;
},

/**
* Manipulates a row of a rendered after it has been rendered. For examples checks the checkbox or focuses an input
* @param record {Object} the data of the record
Expand Down

0 comments on commit 69a184b

Please sign in to comment.