Skip to content

Commit 712fbac

Browse files
committed
Uneditable columns
1 parent a8a2ed2 commit 712fbac

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

Griddly/Scripts/editly.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,15 @@
6161

6262
unbind: function()
6363
{
64+
var self = this;
6465
this.$element.unbind(".editly");
6566
this.$element.find("tbody td").each(function () {
66-
$(this).removeAttr("tabindex");
67+
if (self.options.editors[this.cellIndex] != null) {
68+
$(this).removeAttr("tabindex");
69+
}
70+
else
71+
$(this).css("cursor", "");
72+
6773
});
6874
for (var i = 0; i < this.options.editors.length; i++) {
6975
$(this.options.editors[i]).hide();
@@ -80,9 +86,9 @@
8086

8187
var movement = function (element, keycode) {
8288
if (keycode === ARROW_RIGHT)
83-
return element.next('td');
89+
return element.next('td:tabindex');
8490
else if (keycode === ARROW_LEFT)
85-
return element.prev('td');
91+
return element.prev('td:tabindex');
8692
else if (keycode === ARROW_UP)
8793
return element.parent().prev().children().eq(element.index());
8894
else if (keycode === ARROW_DOWN)
@@ -157,9 +163,10 @@
157163

158164
var showEditor = function (select) {
159165
var last = active;
160-
active = self.$element.find('td:focus');
166+
var newActive = self.$element.find('td:focus');
161167

162-
if (active.length) {
168+
if (newActive.length) {
169+
active = newActive;
163170
template = self.options.editors[active[0].cellIndex];
164171
editor = template.is(":input") ? template : template.find(":input");
165172
validator = editor.parents("form").data('validator');
@@ -180,7 +187,7 @@
180187
}
181188
};
182189

183-
if (last != null) {
190+
if (last != null && last.length > 0) {
184191
var lastTemplate = self.options.editors[last[0].cellIndex];
185192

186193
if (lastTemplate != template) {
@@ -284,13 +291,17 @@
284291
};
285292

286293
this.$element.find("tbody td").each(function () {
287-
if (!this.tabIndex || this.tabIndex < 0)
288-
this.tabIndex = 0;
294+
if (self.options.editors[this.cellIndex] != null) {
295+
if (!this.tabIndex || this.tabIndex < 0)
296+
this.tabIndex = 0;
297+
}
298+
else
299+
$(this).css("cursor", "default");
289300
});
290301

291302
$(this.$element).on("click.editly keypress.editly dblclick.editly", $.proxy(function (e) {
292303
if (doValidation()) {
293-
if(active)
304+
if(active&&active.length>0)
294305
saveActive();
295306
showEditor(true);
296307
} else {
@@ -307,7 +318,7 @@
307318
possibleMove.focus();
308319
}
309320
else if (e.which === ENTER) {
310-
if (active != null && active.tagName == "INPUT") {
321+
if (active != null && active.length > 0 && active[0].tagName == "INPUT") {
311322
possibleMove = movement($(e.target), e.shiftKey ? ARROW_UP : ARROW_DOWN)
312323
if (possibleMove.length > 0) {
313324
possibleMove.focus();

Griddly/Views/Home/Editly.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
$("#edit-text"),
7777
$("#edit-text"),
7878
$("#edit-currency"),
79-
$("#edit-text"),
79+
null,
8080
$("#edit-text"),
8181
$("#edit-bool")
8282
],

0 commit comments

Comments
 (0)