How to add an Extra button on Extjs grid header menu - extjs

has anybody had the need to add an extra button to the grid panel header menu(sorting\columns)?
potentially I would like to add another button to the menu that resets to the default columns model. I can accomplish this using Jquery but I was wondering if there is an EXTjs way to do it.
Thanks

You need to dig through the source to see it's there, but a GridPanel has a view property which is its GridView which in turn has a hmenu property which is the menu it shows when you click on one of those column headers.
So, with a GridPanel called gridpanel (once it's rendered) you can do the following:
gridpanel.view.hmenu.add({
text: 'reset',
handler: function() {
// reset magicks
}
});

Related

Kendo UI grid for AngularJS detail row automatically collapse after inserting itmes into detail data source

I am using Kendo UI grid for AngularJS. The scenario is; I have expanded one master row which contains another grid in its detail template. When I insert new item in the detail template grid, the master row automatically collapsed. what I want is when I making changes to detail template grid than there must be no affect on master row(I mean should not be collapsed). any help will be appreciated.
I know the question is old but I have faced the same scenario and come up with this, when you rebind/refresh grid by any mean, the grid get re rendered and thus you got collapse your row. apparently this behavior is of kendo ui. the only thing you can do is take that expanded row id and then rebind grid, after rebind expand that row again
Try adding a dataBinding function to the grid to cancel the default action on the item Change event.
Example Below:
$("#grid").kendoGrid({
navigatable: true,
sortable: true,
dataBinding: function (e) {
if (e.action == "itemchange") {
e.preventDefault();
}
},
});

ExtJS 4 - how to disable checkbox in a specific row

I have a grid of data in ExtJS 4 which contains a checkbox column. I need to disable the checkbox programmatically after the grid has loaded, following an external AJAX call. (Basically, after making the AJAX call, I need to stop users from changing the checkbox. This is not a store update). I do have a reference to the row itself.
I have seen several similar questions, but they all seem to deal with disabling a row or cell edit when the data is initially loaded.
If I understand you correctly you wan't to stop users editing your grid inline. In order to do this use the processEvent function on your grid and return false so any edit they try to make is immediately returned.
{
xtype: 'checkcolumn',
dataIndex: 'someModelReference',
// Prevents toggling the checkbox inline
processEvent: function() {
return false;
}
}

Component as grid emptyText in ExtJS?

I want to display a component as emptyText for a grid, the ExtJS documentation states that only HTML can be shown.
For example a button that pop-ups a create window, as shown below:
Is there a workaround to use a component in a grid, or perhaps even a config that I'm missing?
Of course you can do that, just that you will have to debug a lot in order to see how to do that. That's why I have an alternative: add a hidden docked toolbar with your "Create new employee" button. Then add an listener for the load store event, and when no records are available, simply show the toolbar, otherwise hide the toolbar.

Which event get fired first when an ExtJS grid inside a view is loaded

I have a view, which contains a grid. The grid is having a grouping feature. I am enabling/disabling the feature based on user interaction. If I disable the feature & close the window, the next time I load the view, the grouping feature remains disabled.
I am wondering, How can i say, as soon as grid is loaded, enable the group feature in the grid. Do we have any event or method to achieve this?
Thanks !!!!!
I guess you could just enable the feature in the afterrender event of the grid
listeners: {
afterrender: function() {
// fancy grouping code
// I'm not really familiar with grouping,
// so I can't provide code for this part
}
}
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.Panel-event-afterrender

Extjs: How to prevent checkboxModel from deselecting rows on pagingtoolbar page change?

Why does CheckboxModel deselect all selected rows on page change when using paging toolbar? How do I stop the deselection of rows on page change?
I see there is a pruneRemoved which can be used to prevent the pruning of nodes, I set it to false, but the deselect is still fired. Not sure what else to try.
I'm assuming checkboxmodel registers with the store or maybe pagingtoolbar to be notified when the store changes...then deselects everything? Why? I need to prevent that.
Edit:
The reason I don't want the deselectAll to be fired is; I attach a handler on select and deselect. Select adds rows to another grid, deselect removes them. So when the user checks a checkbox that row is added to another grid, when they uncheck it it is removed from that grid. By the grid firing a deselectAll, when the store changes, I lose all my saved rows in the other grid.
I'm not sure if this is the correct way to do this but it's working for me.
What I did was create my own Ext.grid.View. I extended ext.view.Table and over-road the onMaskBeforeShow method. This is the method that was calling deselect all on the grids selection model. As you can see I commented it out here
Ext.define('Ext.grid.SteveView', {
extend: 'Ext.view.Table',
alias: 'widget.stevegridview',
onMaskBeforeShow: function(){
var me = this,
loadingHeight = me.loadingHeight;
//me.getSelectionModel().deselectAll();
me.all.clear();
if (loadingHeight && loadingHeight > me.getHeight()) {
me.hasLoadingHeight = true;
me.oldMinHeight = me.minHeight;
me.minHeight = loadingHeight;
me.updateLayout();
}
}
});
Include the above script, then when you create a grid, change the viewType to stevegridview, or whatever you decide to name it
{
xtype: 'grid',
viewType:'stevegridview',
store:'some store'
...
}
The new view type will be used a the new onMaskBeforeShow() will be called.

Resources