I'm using angular ui-grid and have a long grid with almost 30 columns, I want to set fixed width for columns so that at least column header can be seen easily. Is there a way to set, say 10% width for all the columns, or I have to do it for each column one by one.
After setting the min-width on ui-grid-header-cell many columns got combined into one
.ui-grid-header-cell {
min-width: 150px !important;
}
If you are looking for fixed width, you can use the width property in the colomnDefs like this:
columnDefs : [
{ field : 'pageIcon', displayName : 'Page Icon', width : 25},
{ field : 'pageName', displayName : 'Page Name', width : 100},
{ field : 'count', displayName : 'Count', width : '30%'}
]
After you have set your column definitions, you can add the following
for (var i = 0; i < $scope.gridOptions.columnDefs.length; i++) {
$scope.gridOptions.columnDefs[i].width = '10%';
}
This will set all of the columns to the width you select. With 30 columns at 10% the user will use the horizontal scrollbar to see all the columns, as you prefer. I didn't change any CSS.
The best way is to use the GridOptions minimumColumnSize property:
$scope.gridOptions.minimumColumnSize = 100;
Zero performance impact and no oddities with the CSS methods.
Reference page, Ctrl-F minimumColumnSize: http://ui-grid.info/docs/#!/api/ui.grid.class:GridOptions
Try by the following function by calling before ui-grid data source binds.
function SetColumnWidth() {
var cols = _.filter($scope.gridOptions.columnDefs, function (c) {
return c.visible != false;
});
var maxWidth = (document.documentElement.clientWidth) / cols.length;
for (var i = 0; i < cols.length; i++) {
cols[i].maxWidth = parseInt(maxWidth);
}
}
set column width to width: "*" and set minWidth as per convinient.
This solution is work for any screen as, especially large resolution screen. It will manage to equally divide maxWidth of all columns and cover the whole area of the screen.
you can add a style to your css
.ui-grid-header-cell {
min-width: 200px !important;
max-width: 300px !important;
}
If you will add width using for loop or like ways it may slow down rendering of your grid, So I would suggest to do it via CSS. Because I had same problem with 15,000 rows and 80 columns and I tried adding width using loop and it seems to slow down rendering of grid. So, Try adding below code in your CSS, it will solve your purpose.
.ui-grid-header-cell {
min-width: 200px !important;
max-width: 300px !important;
}
.ui-grid-cell {
min-width: 200px !important;
max-width: 300px !important;
}
Related
I have a lot of data in the tooltip of a highcharts bar chart. Each tooltip data has some 50-60 lines and the complete tooltip is not being able to be displayed in the graph container. In order to view all of it, i want a scroll bar in tooltip. Is it possible?
Here is an example of the code.
Working jsFiddle example
Here is the tooltip code. I don't know where to add the scroll bar code.
tooltip: {
useHTML: true,
pointFormatter: function() {
var string = '';
Highcharts.each(toolTip[this.series.data.indexOf(this)], function(p) {
string += p + '</a><br>'
})
return "Incident<br>" + string + "<br />";
}
}
Just add the following CSS:
.highcharts-tooltip>span {
max-height:100px;
overflow-y: auto;
}
However,there would be a problem regarding the auto-closing of the tooltips. You might have to tweak the events of the highchart.
.highcharts-tooltip {
pointer-events: auto !important;
}
.highcharts-tooltip > span {
max-height: 200px;
overflow-y: auto;
}
set overflow-y and pointer-events can scroll On PC. But on mobile, click tooltip will change.
How can I set the width of a ComboBox input field? I tried to set the width and it does not work. I could not find any CSS variable for width though there is one for height ($form-field-height).
I have also tried to set width in fieldStyle.
fieldStyle: {
width: '100px'
}
I am able to change the height though. The following works.
fieldStyle: {
height: '60px'
}
code4jhon answered it, I just want to add some notes: Is your combobox is inside a parent container with a auto-fixed layout type: like hbox, vbox,...? You can't change width and height because it's controlled by its parent layout.
Width does work, you can play with this code to watch it:
https://fiddle.sencha.com/#fiddle/1g3
Best regards.
Can you try this using !important in css,
fieldStyle: {
width: 100px!important;
}
I have the following problem. i have a grid with a custom row height wich is set with css.
my css:
.blubb>td {
overflow: hidden;
padding: 3px 6px;
white-space: nowrap;
height: 27px !important;
}
in getRow class i assign this class to the rows. This works really well the second time i load the grid. When i load the grid for the first time, it looks like this:
So it looks like the Css rules won't get applied to the rows, but why are they applied when i load the grid for the second time? You should also know, that the first 4 columns are locked, so this is a locked grid. Could someone please help me to fix this issue? Thx in advance!
instead of using the getRow, you can use the tdCls property in your Ext.grid.column.Column see here, or you can define a custom column:
Ext.define('Ext.ux.grid.StyleColumn', {
extend: 'Ext.grid.column.Column',
alias: 'widget.stylecolumn',
/* author: Alexander Berg, Hungary */
defaultRenderer: function(value, metadata, record, rowIndex, colIndex, store, view) {
var column = view.getGridColumns()[colIndex];
//we can use different classes in each cell
if (record.data.tdCls) {
metadata.tdCls = record.data.tdCls;
//we can use different classes in each column
} else if (column.tdCls) {
metadata.tdCls = record.data.tdCls;
//we can use different classes in each grid (you can define it in viewConfig)
} else if (view.rowCls) {
metadata.tdCls = view.rowCls;
//we can add a default class
} else {
metadata.tdCls = 'mydefault';
}
return value;
}
});
I use Ext.grid.Panel in my project, but I think the default row height is too large and I can't modify the row height, so the whole grid makes me feel uncomfortable.
However, I find the panel-grid example in Extjs-4 doc is quite good. In it the row height is adjusted to fit the words height.Thus the whole grid is very compact.
So I wonder how can I set the grid row height?
One way you could change the row height is by using css. Each row uses padding along with the content for the height so if you were change the padding in this class it would make the row higher/lower:
.x-grid-cell-inner {
overflow: hidden;
padding: 3px 6px;
white-space: nowrap;
}
Also, you can take a look here:
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.view.Table-method-getRowClass
The following code uses a getRowClass function for the grid to specify a CSS class for specific rows:
JavaScript Code
viewConfig : {
forceFit : true,
getRowClass : function(record, index) {
if (index % 2 == 0)
return "red";
else
return "green";
}
},
The height can then be modified with CSS:
CSS Code
.red .x-grid-cell {
background-color: #FFFFDD;
height: 30px;
}
I have a gridpanel and 5 columns in that. Problem is that column headers and row data are not aligned. I believe its just the problem in my project only as when i create an example with the same code then everything works fine. Check the following image:
Can anyone suggest what could be the problem?
Please apply below css as per the requirements.
1) For Customizing specific ExtJS GridPanel, apply below css:
#testgrid_id table caption,table th,table td {
padding : 0px !important;
margin : 0px !important;
}
Note: Here, above "#testgrid_id" is the id of specific Grid Panel.
2) For applying to all ExtJS GridPanels, apply below css :
table caption,table th,table td {
padding : 0px !important;
margin : 0px !important;
}
Thanks!
Actually I found out that most times, the grid is under some panel.
Hence the actual problem is with this class
.x-grid-cell-inner
{
overflow: hidden;
padding: 2px 6px 3px;
**text-overflow: ellipsis;
white-space:nowrap;**
}
This is because the width of the or
<td class=" x-grid-cell x-grid-cell-gridcolumn-1099 "><div class="x-grid-cell-inner "></div></td>
Does not get set. Making the Div overflowing the columns and screwing up the whole grid alignment.
Probably because i nested the GridPanel into another panel OR a Row expander in my case or under some modal dialogue or whatever it may be causing the settings not to take place.
A Quick Fix.
**white-space:normal;**
Will do the trick and squeeze the contents into the column. However it does not apply the ellipses so it is a bit annoying if the content is long, its not hidden with "..."
I will try to find another solution that does the trick, but guess what, time to deploy this to the server!
I hope this helps someone
I have this bug using GXT 2.2.5 (Chrome Version 26.0.1410.43m).
Solution:
#media screen and (-webkit-min-device-pixel-ratio:0) {
.x-grid3-row td.x-grid3-cell
{
box-sizing: border-box;
}
}
Note, if your CSS contains something like:
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
remote it.
I had exactly the same problem.
For me the problem was, was that I was setting HTML ids on my column headers. ExtJS then appends funny things to the ID, like titleEl, textEl, triggerEL.
Eg:
<div id="myPackageGridId1-titleEl" class="x-column-header-inner">
This must somehow screw up the column listener.
Solution : use class instead.
In my case (GXT 2.2.1) I fixed the problem by subclassing GridView, overriding getColumnStyle, and setting adj to 0:
import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.Style;
import com.extjs.gxt.ui.client.widget.grid.GridView;
public class GridViewBugFix extends GridView {
private boolean fixHeaderDisplacement = true;
public GridViewBugFix() {
super();
}
#Override
protected String getColumnStyle(int colIndex, boolean isHeader) {
String style = !isHeader ? cm.getColumnStyle(colIndex) : "";
if (style == null) {
style = "";
}
int adj = GXT.isWebKit ? 2 : 0;
if (fixHeaderDisplacement) adj = 0;
style += "width:" + (getColumnWidth(colIndex) + adj) + "px;";
if (cm.isHidden(colIndex)) {
style += "display:none;";
}
Style.HorizontalAlignment align = cm.getColumnAlignment(colIndex);
if (align != null) {
style += "text-align:" + align.name() + ";";
}
return style;
}
}