I have a treepanel with a widget column. The widget column is defined like so:
{
xtype: 'widgetcolumn',
width: 80,
dataIndex: 'slider',
widget: {
xtype: 'slider'
},
onWidgetAttach: function(col, widget, rec) {
widget.setVisible(rec.get("leaf"));
}
}
So, the task is to show or hide slider widget, depending on the type of the node. If it is a leaf node, then the widget should be visible, otherwise it should be hidden. The way I do it is through onWidgetAttach method. But this is what I get as a result:
Please, pay attention to some leaf nodes that do not have a widget. Unfortunatelly, I can not provide a reproducible example, because of the random nature of this bug. If, for example, I refresh the panel multiple times, then in some rows widgets appear, and in some others disappear. It behaves just like a random number generator. So, what may be wrong with that and how can I fix it?
Related
Currently I am learning ext.js 6 and I have a quastion to ask.
I want to build a tree-like menu and from examples I know how to build all kinds of trees. But how can I change a view when user clicks on different leefs in a tree? I know I need controller(viewcontroller) and handlers to work with events (onClick and such) but how to render views from there?
Thank you.
You need to use add() function for that:
add( component ) : Ext.Component[]/Ext.Component
Adds Component(s) to its parent.
You need to pass the view to be rendered as parameter
Eg. Adding a formpanel & button directly to the view port:
Ext.Viewport.add([
{
xtype:'formpanel'
},
{
xtype:'button'
}
]);
Im my application (its use ExtJS 4 actually, but I guess idea is the same) I do something like this:
var viewport = Ext.create('Ext.container.Viewport', {
alias: 'widget.viewport',
layout: 'border',
items: [
// Its my main menu, displayed on all pages
portalToolbar,
{
xtype: 'panel',
itemId: 'mainPanel',
layout: 'fit',
region: 'center'
}
]
});
And on menu item click I remove any content from main panel and add new one, like this:
// remove previous page from main panel,
// think about `abort()`ing all ajax requests, clear intervals and so on along with this
mainPanel.removeAll();
// `currentInterface` is any component that is one of the pages of my application
mainPanel.add([currentInterface]);
Also you can take a look at Ext.util.History and on menu click add new token to history and on history change event open application page like described above.
I'm a little new to Extjs and I'm trying to figure out the proper way to show/hide elements.
I have the following elements:
layout: 'card',
items:
[
{
xtype: 'Panel1'
},
{
xtype: 'Panel2'
}
]
In my controller I have these references setup:
refs: [
{
ref: 'p1',
selector: 'Panel1'
},
{
ref: 'p2',
selector: 'Panel2'
}
],
Each panel has a form and two buttons at the bottom. Panel 2 is hidden in the beginning. Now I want to show Panel 2 and hide Panel 1. First I tried:
this.getp1().hide();
this.getp2().show();
...and that did nothing. Then, I found this SO question and tried out the following:
this.getp1().getEl().hide();
this.getp2().getEl().show();
which partially worked except that it failed to also show the buttons in Panel2. Am I supposed to get every single element and show() each of them? I must be missing something.
try with:
this.getP1().hide(); //the first letter should be uppercase
this.getP2().show();
The parent panel of my two problem items was of a layout: 'card'. According to the sencha docs on the Card layout only one panel will be shown at a time. Therefore, the proper way to show other items is not via the show/hide function, but rather calling
PARENT_PANEL.getLayout().setActiveItem(n); That was causing my p2 panel to always be hidden and not affected by the show() method.
I'd like to add a column with checkboxes in a rally grid (something like "Select Default"). It looks like that should be pretty simple using the 'checkcolumn' xtype. But that requires you to link in some additional extjs styles, and I'm not sure how to do that within the Rally extjs framework:
Extjs 4 checkcolumn not visible
Here's an example of such a column in ext-js: http://dev.sencha.com/deploy/ext-3.4.0/examples/grid/edit-grid.html
Is there a way do this with a Rally grid?
I ended up using a quick and dirty solution based on the anwser below:
{text: 'Default', dataIndex:'selected', align: 'center', width: 50, renderer: function(value, style, item, rowIndex) {
return "<input type='radio' name='primaryIndex' alt='"+ rowIndex + "' " + (value ? "checked='checked'" : "") + ">";
}},
AND:
checkRadioClick: function(event) {
var button = event.getTarget('input[type="radio"]');
if (button) {
...
Currently Ext's grid (which the Rally grid extends) doesn't support a checkbox column. The closest thing that comes out of the box is the Boolean column:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.column.Boolean
This is because the grid expects you to have to click a cell to initiate an edit and a checkbox column is immediately editable without that action.
That given, I think you should be able to render a checkbox column by simply specifying a renderer for that column in your column config. It may be a little challenging to get the values back out of the grid when they change though since the values will not have been committed to the underlying records in the store (because no actual edit was triggered).
There is also a user submitted CheckColumn here that you may be able to use or at least as an example to get started:
http://docs.sencha.com/ext-js/4-1/source/CheckColumn.html#Ext-ux-CheckColumn
Maybe this is new with one of the newer preview versions? I did this:
Ext.create( 'Rally.ui.grid.Grid', {
selType: 'checkboxmodel',
selModel: {
injectCheckbox: 1,
mode: 'SIMPLE',
listeners: {
selectionchange: function( model, selected ) {
// do stuff
},
scope: this
}
}
I'm creating a rally grid for portfolio items using the 2.0 SDK, and including the "PlannedEndDate" field. This is really nice, because it brings up a calender editor if somebody wants to edit the field.
But I want to make the PlannedEndDate smaller than the standard width. But, when I do that, I loose the nice editing feature and other defaults. How do I change the width, but not loose all the other nice defaults?
I'm changing columnCfgs From:
PlandEndDate,
To:
{ dataIndex: 'PlannedEndDate', width: 35, text:'Planned End' }
Do I need to use some fancy xtype or something?
If you add this to your PlannedEndDate column config it should work:
editor: {
xtype: 'rallydatefield',
format: Rally.util.DateTime.getUserExtDateFormat(),
validateOnChange: false
}
We hope to do some refactoring around the way columns are handled in the grid to make things like this easier.
I am trying to create a custom container but can't figure just how to do it.
I need it to look like this:
(don't pay attention that it is RTL, this is only a sketch to get started)
where the orange fonts are the title of the page that I would like to be an H1 element.
It has a simple search and an advance search that pops open when the little arrow next to the search button is clicked.
Questions:
1) What should I extend for that ?
2) How can I implement different advance search forms for different pages ?
3) how can I place a setter for the title that controllers can interact with and manipulate the dom ?
basically any advice will be good as I need a start point.
thanks
There are lots of ways of doing this, but this is what I would do.
I'm not sure about the "advanced forms for different pages" can you go into mre detail about that? Are you looking to autogenerate a search form somehow?
Extend Ext.form.Panel, and use a table layout for the fields
See: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.layout.container.Table
use a "tbar" on the panel instead of setting "title". you can place the search combo, tbfill, then a tbtext for the "title". As a convenience you can override the setTitle function of the panel to manipulate this tbtext field instead of the normal behavior. Something like this:
Ext.define('MyApp.view.MyForm', {
extend: 'Ext.form.Panel',
alias:'widget.myform',
layout:{
type: 'table',
columns: 4,
tableAttrs: {
style: {
width: '100%'
}
}
},
//overridden setTitle
setTitle:function(title){
Ext.getCmp(this.id + "_search_combo").setText(title)
},
defaults:{
xtype:"combo",
//rest of combo config here
},
items:[{
//...
}],
initComponent:function(config){
this.tbar = tbar:[{
xtype:"combo",
//...
id:this.id + "_search_combo"
},{
xtype:"tbfill"
},{
xtype:"tbText",
cls:"my_form_title",
value:this.title||""
}]
//prevent default title behavior
delete this.title
this.callParent(arguments);
}
})
I would suggest you to just extend from Ext.panel.Panel itself, and hijack the dom for all those customized items, add in search bar, etc. If you do not want any of the fancy stuff from Ext.panel.Panel, you can also extend it from Ext.Component, or Ext.container.Container (to contains more components), and even the lowest Ext.util.Observable.
It seems like you might need to extend a few Ext.menu.Menu and defines some different set of input boxes, so that you could benefit from creating a floated menu (if that's what you want). Or if you have time, you can even just extend from Ext.Component and build your own customized component, or even lower, Ext.util.Observable.
The setter? It will be in the extended component in (1) then :)
All of these serve as rough opinions. They could be different depends on your requirement.