Hide grid Panel Column programmatically ExtJs 5 - javascript

I want to hide a column in grid panel of ExtJs 5 when store associated with grid panel loads .

Depending on how your data store works.... there is onload event. Hide your column on that event.

Using the following syntax you can achieve it:
<yourGrid>.down('headercontainer').getGridColumns()[<columnIndex>].hidden = true;

If you know the index of the column to hide you can use this code after store load event fired
grid.getColumnManager().getHeaderAtIndex(indexOfColumn).hide()

You can find the api from manual [Ext.grid.column.Column-method-hide]: http://docs.sencha.com/extjs/5.0/5.0.1-apidocs/#!/api/Ext.grid.column.Column-method-hide
There is a fiddle for you: http://runjs.cn/code/qusp7pql

Related

Trigger jQuery event on Bootstrap data-show-columns

In one of my projects I am using a Bootstrap table for displaying and manipulating data. I also use data-show-columns="true" in order to allow the user to show/hide needed columns in the table.
When it is used it messes up some of the styling in the table.
Is there any way that I can trigger the jQuery event or call JavaScript function when I use data-show-columns functionality of Bootstrap table?
This is a good example of a table with data-show-columns functionality. It is not my code. All I need is to somehow trigger the jQuery event on columns show/hide.
Thank you,
It should be:
$("#yourTableId").on("column-switch.bs.table", function() {
....
....
});

Javascript event on form add fields

I've got a rails app using bootstrap with a form page that has the option to add additional form fields. The tutorial from this Railscast episode heavily influenced this form page add fields feature. I have a need to watch the add fields so that I can hide a warning panel in the new well created. Here is the code that will not work(in coffeescript):
$('#classifications_forms').on 'change', (event) ->
container = $('.classifications_form').last()
$('#premium-divide', container).hide()
Here is the code in jquery:
$('#classifications_forms').on('change', function(event) {
var container;
container = $('.classifications_form').last();
return $('#premium-divide', container).hide();
});
I have tried an on click event for the add fields button, but it's late in the event watching as it will not hide the panel. If I hit the button a second time, it will hide the panel on the previously created well, so I know the code was working to hide the panel. My thinking is to hide the panel on the last well created, and I thought that a change on #classifications_forms would give me the event needed to hide the last well, but I guess its missing something on the event. What is missing above?
Here is a jsfiddle demonstrating the problem.
Because I was using bootstrap, I found a class to apply to the panel which took care of my problem:
.hidden

Angular ng- grid - hide/remove column input from column menu

When you use the flag 'showColumnMenu' with true value.
the ng-grid is rendered with button on the right end top panel.
Using this button we can hide/show the column on the grid.
In my Case I don't want to make it possible for some column to be visible on the grid - Meaning I want the the column menu box will be rendered with out some column.
Iv'e created plunker which demonstrated my problem
> http://plnkr.co/edit/VXOzBIRfyY3FoCTct9PI?p=preview
In that plnkr - I set column 'Id' to be invisible using (visible: false)
But if the user click on the column menu on the right end panel
he will be able to set it visible..
EDIT
Another scenario that I need to cover is case where there is some other
column say 'name' that I don't want the let the user configure it (by setting it as invisible) inside the column menu - meaning that column 'name' must always be on the grid!
and the user does not need to see it in the column menu..
So, if only i could hide those columns (id,name) inside the column menu
my problem will be solved..
Thanks!
You can do that editing a bit menuTemplate.html in ng-grid source file
Find line starting from :$templateCache.put('menuTemplate.html',
and line
<label><input ng-disabled=\"col.pinned\" type=\"checkbox\" class=\"ngColListCheckbox\" ng-model=\"col.visible\"/>{{col.displayName}}</label>\r" +
change to
<label ng-hide=\"col.colDef.alwaysVisible\"><input ng-disabled=\"col.pinned\" type=\"checkbox\" class=\"ngColListCheckbox\" ng-model=\"col.visible\"/>{{col.displayName}}</label>\r" +
now you can add
alwaysVisible:true
to columnDefs and it's done
Please see here working demo http://plnkr.co/edit/qmoILJ5LTMSlH7Uv9Rw8?p=preview
Why not just turn off the column menu? It sounds like you basically don't want to use it anyway. Is it important for your users to be able to hide the age column, when they can't control any other?
For hiding ID, I'd recommend not putting in the list of columns in the first place. Even if you don't include it in the grid, it will still be present in the data and accessible by your code. The grid is just a place to display information to the user, so don't put info in there that you don't want to display.
Edit: Check out UI-Grid, the updated version of the Ng-Grid project: http://ui-grid.info/
It has a new ColumnDef property, "EnableHiding" for exactly this case.
Here's their documentation for upgrading from ng-grid: http://ui-grid.info/docs/#/tutorial/099_upgrading_from_2

Dynamically created selectors in jQuery

Hi I am trying to dynamically create a selector for jQuery instead of using a static one. The problem is, it is not working predictably/consistently.
I created a fiddle here: http://jsfiddle.net/Cc92f/
If you click run and click in each of the top radio buttons once, they work, but you cannot use the same buttons a second time.
If you click a top button, and then a bottom button, you can no longer click any of the buttons.
You may have to reload it a couple of times to see how different uses break it in different ways.
Thanks you for any and all help!
$(".concattest").click(function(event)
{
var radioid=event.target.id.split("_");
$('#r_2_'+radioid[2]).attr('checked', 'checked');
event.preventDefault();
});
Use .prop('checked',true) instead of .attr('checked','checked').
http://jsfiddle.net/5LWEk/
If you want to:
When changing selection in the top row, change value of bottom row
accordingly
When changing selection in the bottom row, select the last option in
the top row
Then use change event and prop() function, here is the demo

Extjs adding panel's button to parent window's bbar?

I have a button in a panel which gets rendered inside a window. And I want to be able to add that button to a bottom bar in the window.
Current I am trying to add an onRender function to the panel to get the parent window using
this.findParentByType('Ext.Window')
however it returns null.
I am even heading in the right direction?
EDIT: I am using extjs 3.2.2
findParentByType takes xtype as parameter. So in your case you should use
this.findParentByType('window')
or
this.up('window')
Have you tried providing a unique id to your window and adding the buttons to it like so:
Ext.getCmp('myWindowId').add(buttonPanel);
#Nitin Singhal #Reflux
For ExtJS4: Ext.ComponentManager.get('html dom id')

Categories

Resources