Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bootstrap tab plugin and row selection plugin #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions plugins/KoGridRowSelectionPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// use this plugin if you need to change the selection programmatically
var KoGridRowSelectionPlugin = (function () {
function KoGridRowSelectionPlugin(selectedItems) {
this.selectedItems = selectedItems;
}
KoGridRowSelectionPlugin.prototype.onGridInit = function (grid) {
var _this = this;
this._grid = grid;

this.selectedItems.subscribe(function (newValues) {
if (_this._grid.$$selectionPhase == true)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (_this._grid.$$selectionPhase == true)
if (_this._grid.$$selectionPhase === true)

should be === right

return;

for (var j = 0; j < newValues.length; j++) {
var newValue = newValues[j];

for (var i = 0; i < _this._grid.rowFactory.rowCache.length; i++) {
var rowCache = _this._grid.rowFactory.rowCache[i];
if (rowCache.entity == newValue) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (rowCache.entity == newValue) {
if (rowCache.entity === newValue) {

should be using ===

_this._grid.selectionService.setSelection(rowCache, true);
_this._grid.selectionService.lastClickedRow = rowCache;
break;
}
}
}
});
};
return KoGridRowSelectionPlugin;
})();
koGridRowSelectionPlugin = KoGridRowSelectionPlugin;
19 changes: 19 additions & 0 deletions plugins/koGridBootstrapTabPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// extension of the LayoutPlugin. Needed if the grid is displayed on a tab within bootstrap.
koGridBootstrapTabPlugin = function () {
var self = this;
this.grid = null;
$("a[data-toggle='tab']").on("shown.bs.tab", function () {
self.updateGridLayout();
});

// The init method gets called during the koGrid binding handler execution.
self.onGridInit = function (grid) {
/* logic */
self.grid = grid;
};
this.updateGridLayout = function(){
window.kg.domUtilityService.UpdateGridLayout(self.grid);
self.grid.configureColumnWidths();
window.kg.domUtilityService.BuildStyles(self.grid);
};
}