Null selection error on Bryntum Kanban Task click - extjs

I am working on integrating the Bryntum Kanban board into an EXTJS application. In the top toolbar of the kanban, I have an ExtJS combobox that changes the view so that users can view their private taskboard as well as the taskboard for their groups. (Users can be in more than one group) When the view is changed, both the statestore that populates the columns of the taskboard and the userstore that populates the userpicker need to reload, as well as the taskstore. The problem is that after the view is changed, clicking on a task throws two errors:
Uncaught TypeError: can't access property "getRange", this.selected is null
ExtJS 2
relayMethod http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:6471
map ExtJS
relayMethod http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:6470
deselectAll http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:6446
deselectAll http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:7431
onDragStarting http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:7532
ExtJS 4
getDragData http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:4896
ExtJS 86
ext-all-debug.js:200495:9
and
Uncaught TypeError: can't access property "getRange", this.selected is null
ExtJS 2
deselectAllInOtherSelectionModels http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:6465
each ExtJS
forEachSelModel http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:6475
deselectAllInOtherSelectionModels http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:6464
deselectAllInOtherViews http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:7385
onTaskClick http://dev.southern-air.com/javascript/taskboard/taskboard-all-debug.js:7381
ExtJS 2
ext-all-debug.js:200495:9
Here is the code for the change listener on the combobox:
change: function (field, newValue) {
var ts = Ext.data.StoreManager.lookup('taskstore');
var ss = Ext.data.StoreManager.lookup('statestore');
var us = Ext.data.StoreManager.lookup('userstore');
var taskboard = field.up('mytaskboard');
console.log(taskboard);
ts.getProxy().setExtraParam('view', newValue);
ss.getProxy().setExtraParam('view', newValue);
us.getProxy().setExtraParam('view', newValue);
taskboard.deselectAll();
ss.reload({
callback: function () {
// taskboard.deselectAll();
taskboard.refresh();
us.reload({
callback: function () {
taskboard.userMenu.picker.refresh();
ts.reload({
callback: function () {
console.log(taskboard);
}
});
}
});
}
});
}
Is there anything that I need to do before I reload the stores to ensure that this error is not thrown? If anyone has also had this problem I'd appreciate your solutions. I have tried deselecting all before reloading, as you can see in the code above, but that doesn't help either.

After troubleshooting, I was able to find a solution that seems to be working. I had to add the following line to the change listener before reloading the stores:
delete field.up('mytaskboard').selModel;
This line deletes all the selection models from the taskboard, which were the things that were causing the problem in the first place. Now the views change and everything works as expected. I am still interested to know if this may cause other issues down the line though.

Related

get all dialogs in page in AEM

Is there any direct way to get dialog object of all components which are dragged on page.
For ex: when we load page and if there is any component like text, image are on page, I can get dialog. Please suggest?
Yes, it is possible. Attach a listener which listens to the editablesready event fired by WCM. Get all the editables on the page using the #getEditables() method of CQ.WCM and then get the dialog of each editable if it is present.
Sample code below.
CQ.WCM.on('editablesready', function() {
var editables = CQ.WCM.getEditables();
for(var path in editables) {
var editable = editables[path];
try {
console.log(editable.getEditDialog());
//Do stuff
} catch(e) { }
}
});

How to specify filtered Backbone collection for Marionette view

I have a Marionette composite view that displays a collection, which I set in my Application start handler:
App.on('start', function() {
Backbone.history.start({pushState: true});
// I load up this.appsCollection in my before:start handler
var tblView = new this.appsTableView({
collection: this.appsCollection
});
this.regions.main.show(tblView);
});
This works as expected, displaying my entire collection. In my models, I have a state field, and I want to display only models with state 0. I tried:
collection: this.appsCollection.where({state: 0})
but that doesn't work. I actually want to display states in 0 and 1, but I'm trying to just display state in 0 for right now.
What am I missing?
The problem probably resides in that .where() doesn't return a collection, but an array. http://backbonejs.org/#Collection-where This was supposedly to maintain compatibility with underscore.
If you change the line to:
collection: new Backbone.Collection( this.appsCollection.where( { state: 0 } ))
Does that help?
I was able to override the filter method in my Marionette CompositeView:
http://marionettejs.com/docs/v2.4.3/marionette.collectionview.html#collectionviews-filter

Angular - kendo data binding

I'm using a kendo grid and have a checkbox column with the following template:
"<input class='gridCheckbox' id='gridCheckbox_#=name#' name='Selected' type='checkbox' ng-model='dataItem.checked'/>"
In addition I'm also using an observableArray as the grid's dataSource.
When clicking the chekcbox the data in the observableArray is changed as expected but no "change" event is triggered.
Here is how I define the observableArray:
var obsArray = new kendo.data.ObservableArray(scope.gridData);
this.gridDataSource = new kendo.data.DataSource({
data: obsArray
});
obsArray.bind("change", function (e) {
console.log(e.action, e.field);
});
"scope.gridData" is the original dataModel. When I click the checkbox the observableArray is changed but not the "scope.gridData". In order to change the "scope.gridData" I want to listen to the "change" event and change the "scope.gridData" manually but as I said the "change" event is not triggered.
Any suggestions to what am I doing wrong and maybe there is a better solution.
Read This
your issue is that kendo uses a copy of your scope object
I manually added an event to my input checkbox (in our class we're using Angular so it was on ng-click="doSomething()" but maybe yours is just click="doSomething" and recorded handling the boolean change manually.
We have the Kendo Observables, too - but I got **lucky because we're also using the Breeze JS stuff where we can do data detection and refresh the grid once the data propagates backwards to the right place to be set to dirty. ( grid.dataSource.read(); )
If you want the full row value, make the click="doSomething(this)" and then capture it as the Sender. Just debug in and you should the dataItem attached to the Sender.
This might help you & this is not the correct figure but i did one example like this similar to your problem
var contentData = [
{ organization: 'Nihilent', os: 'Window' }
];
var nihl = contentData[0];
var viewModel = kendo.observable({
gridSource: new kendo.contentData.DataSource({
contentData: contentData
})
});
kendo.bind($(document.body), viewModel);
contentData.push({ organization: 'Dhuaan', os: 'Android' });
nihl.set('os', 'iOS');

how to reload gird data after add new data in to the store

I have two grids; I call them child and parent grid. When I add a new row(data) into the parent grid, I want to reload the parent grid. I was trying to edit it using the afteredit function in the code. If I uncomment out line number 2 in the alert, that works fine. But with out the alert, the newly added row is hidden. I don't understand what's going wrong in my code. Please can anyone tell me what to do after I add the new row in to my grid and how to reload the grid immediately?
this my afteredit function
afteredit : function (roweditor, changes, record, rowIndex)
{ //alert('alert me');
if (!roweditor.initialized) {
roweditor.initFields();
}
var fields = roweditor.items.items;
// Disable key fields if its not a new row
Ext.each(fields, function (field, i) {
field.setReadOnly(false);
field.removeClass('x-item-disabled');
});
this.grid.getSelectionModel().selectRow(0);
this.grid.getView().refresh();
},
xt.ux.grid.woerp =
{
configRowEditor:
{
saveText: "Save",
cancelText: "Cancel",
commitChangesText: WOERP.constants.gridCommitChanges,
errorText: 'Errors',
listeners:
{
beforeedit: WOERP.grid.handler.beforeedit,
validateedit: WOERP.grid.handler.validateedit,
canceledit: WOERP.grid.handler.canceledit,
afteredit: WOERP.grid.handler.afteredit,
aftershow: WOERP.grid.handler.aftershow,
move: WOERP.grid.handler.resize,
hide: function (p)
{
var mainBody = this.grid.getView().mainBody;
if (typeof mainBody != 'undefined')
{
var lastRow = Ext.fly(this.grid.getView().getRow(this.grid.getStore().getCount() - 1));
if (lastRow != null)
{
mainBody.setHeight(lastRow.getBottom() - mainBody.getTop(),
{
callback: function ()
{
mainBody.setHeight('auto');
}
});
}
}
},
afterlayout: WOERP.grid.handler.resize
}
},
AFAIK RowEditor is a plugin for GridPanel which changes underlying data which comes from store. Usually updates are also made by store. If you want to know when data is saved, you should attach event handler to store. Example:
grid.getStore().on('save', function(){ [...] });
Finally i found solution. When i add reload function in to the afteredit method that will be hide newly added row. So Grid reload After commit data in to that data grid store work well for me. Anyway thanks lot all the people who try to help
this my code look like
record.commit();
grid.getView().refresh();
I think there exist a Save button after editing grid.
So in the handler of Save you can catch the event
or using
Ext.getCmp('your_saveButtonId').on('click', function(component, e) {
// Here they will be checking for modified records and sending them to backend to save.
// So here also you can catch save event
}

EXTJS Mouse click not working after load a page for multi time

I have a grid on my panel, named gridView, and gridView is in panel named panelMain, by dbclick listener on grid row, I load a from by doing something like this:
listeners:{
itemdblclick: function(dataview, index, item, e) {
/* I did not create new studentForm every time.*/
var editStudent = Ext.getCmp('editStudent');
if(editStudent == undefined)
editStudent = Ext.create('H.view.EditStudent');
editStudent.getForm().load({
url: 'studentDetails.php',
params: {studentId: studentId},
method:'GET',
success: function (form, action) {
var panelMain = Ext.getCmp('panelMain');
panelMain.items.clear();
panelMain.add(editStudent);
panelMain.update();
panelMain.doLayout();
},
failure: function (form, action) {
/// do nothing
}
});
}
After I edited the student I should come back to grid page, so I do something like this:
var panelMain = Ext.getCmp('panelMain');
var gridView = Ext.getCmp('gridView');
panelMain.items.clear();
panelMain.add(gridView);
panelMain.update();
panelMain.doLayout();
The problem is when I come back to the grid, it does not fire any itemdbclick event any more (it's like the grid is just an image in page, no event fires).
And sometimes when I go to edit studentForm and come back grid work, but when I go to student form again, the student page does not fire any event, when I click edit button, I do not get any answer, I cant see even on mouse hover (that causes changes on button color).
What is the problem here?
I use Extjs 4 and Extjs MVC.
I have one Controller for grid and edit student page.
I think your misunderstand the success config on form.
Try:
listeners:{
itemdblclick: function ( gridView, record, item, index, e, eOpts ) {
var editStudent = Ext.getCmp('editStudent');
if(editStudent == undefined)
editStudent = Ext.create('H.view.EditStudent');
/* Load record in the form.
Form must have on formfields property: 'name' equals to 'dataIndex' */
editStudent.getForm().loadRecord(record);
var panelMain = Ext.getCmp('panelMain');
panelMain.items.clear();
panelMain.add(editStudent);
}
success and failure are the callbacks functions for the submit function.
a) You are not using MVC pattern here. With what Sencha calls MVC, you would have all this code in a Controller instead of event listener.
b) I strongly suspect that this code causes deadlocks somewhere, with events firing so rapidly in succession that browser just freezes. You need to use debugger to see what exactly happens.

Resources