ANGULAR-JS : Angular UI-GRID width changing - css

I implemented angular ui-grid which should look like:
Angular ui-grid
But in some scenarios it is becoming like:
Shrinked grid
I need the solution so that the grid width remains intact like in the first image.
It generally shrinks when i hit F12 and then navigate for grid to some other page and then come back.
My grid options are:
$scope.gridOptions = {
enableRowSelection : true,
enableRowHeaderSelection : false,
multiSelect : false,
enableColumnMenus : false,
columnDefs : [ {
"field" : "title",
"displayName" : "Title",
"visible" : true,
"enableHiding" : false,
}, {
"field" : "description",
"displayName" : "Description",
"visible" : true,
"enableHiding" : false
}, {
"field" : "dueDate",
"displayName" : "Due Date (mm/dd/yyyy)",
"cellFilter" : "date:'MM-dd-yyyy HH:mm a'",
"visible" : true,
"enableHiding" : false
}, {
"field" : "status",
"displayName" : "Status",
"visible" : false,
"enableHiding" : false
}, ]
};
HTML:
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="panel panel-default">
<div ui-grid="gridOptions" ui-grid-selection class="grid height-250"></div>
</div>
</div>
Thanks

From looking at the documentation for angular ui grid : http://ui-grid.info/docs/#/tutorial/101_intro, I can make the following suggestions:
Do you have your css defined to something like :
.grid {
width: 500px;
height: 250px;
}
Do you have data in the right format in $scope.gridOptions.data? Are you overriding grid css using eg: float. Its hard to say without a sample plunker.
Have you included the grid css.
I saw the example plunker in the documentation for GridUI: http://plnkr.co/edit/?p=preview and I tried several things, but it was always showing the right width. So its likely to be your external css breaking the layout.
Inspect when its breaking and look for what css is being applied to the shrunk columns and then compare that to the working one. That's the best suggestion I can give here.

Related

CKEDITOR is unable to apply styles from an external stylesheet (configured in config.contentscss) when config.fullPage=true

In order to define custom StyleSet in CKEditor with styles from an external stylesheet, configured the following settings:
config.extraPlugins = 'stylesheetparser';
config.contentsCss = '/css/externalStyleSheet.css';
config.stylesSet = [ { name : window.parent.getResource('editor.style.normal'), element : 'span', attributes: { 'class': 'formatnormal' } }, { name : window.parent.getResource('editor.style.small'), element : 'span', attributes: { 'class': 'formatsmall' } }, { name : window.parent.getResource('editor.style.large'), element : 'span', attributes: { 'class': 'formatlarge' } }, { name : window.parent.getResource('editor.style.bold'), element : 'span', attributes: { 'class': 'formatbold' } }, { name : window.parent.getResource('editor.style.smallBold'), element : 'span', attributes: { 'class': 'formatsmallbold' } }, { name : window.parent.getResource('editor.style.largeBold'), element : 'span', attributes: { 'class': 'formatlargebold' } }, { name : window.parent.getResource('editor.style.red'), element : 'span', attributes: { 'class': 'formatred' } }, { name : window.parent.getResource('editor.style.code'), element : 'span', attributes: { 'class': 'formatcode' } }, ];
config.fullPage = true;
config.resize_enabled = false;
config.removePlugins = 'resize,autogrow,elementspath';
Expected result
The styleset should show the list of custom styles.
Once a text is selected, and a style is selected from the drop-down, the style should get applied.
Actual result
The styleset is showing the list of custom styles with the styles applied to the labels themselves.
But, when a text is selected inside the editor (which is in an iframe) and a style is selected from the drop-down, the style is applied to the "span" tag but the corresponding CSS is not present in context of the iframe.
Other details
When config.fullPage = false, then there is no issue, probably because the editor is not in a different iframe and the CSS is available to it. The issue is with config.fullPage = true, which is required in our case in order to have a vertical scrollbar.
Browser: Chrome Version 66.0.3359.181
OS: Windows 10
CKEditor version: 4.9.2
Installed CKEditor plugins: none, other than the configuration mentioned above.
That is documented behavior:
contentsCss : String | Array
The CSS file(s) to be used to apply style to editor content. It should reflect the CSS used in the target pages where the content is to be displayed.
Note: This configuration value is ignored by inline editor as it uses the styles >that come directly from the page that CKEditor is rendered on. It is also ignored in the full page mode in which the developer has full control over the page HTML code.
Read more in the documentation and see the SDK sample.
https://docs.ckeditor.com/ckeditor4/latest/api/CKEDITOR_config.html#cfg-contentsCss
You could load the css in the webpage using ckeditor on, similar to https://jsfiddle.net/z23qxw1y/
CKEDITOR.stylesSet.add('my_styles', [
// Block-level styles.
{
name: 'Blue Title',
element: 'h2',
styles: {
color: 'Blue'
}
},
]);
CKEDITOR.config.stylesSet = 'my_styles';

CSS file not being included?

You might want to read the [update] first, as the nature of the problem has changed.
I am trying to add charting to an AngularJs app. I get the following error
angular.js:13236 Error: Please set height and width for the chart element
at validateHeightAndWidth (https://rawgit.com/chinmaymk/angular-charts/bower/dist/angular-charts.js:138:15)
at link (https://rawgit.com/chinmaymk/angular-charts/bower/dist/angular-charts.js:106:7)
at http://localhost/plafotrm_2/js/angular/angular.js:9486:44
at invokeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:9492:9)
at nodeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8978:11)
at compositeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8226:13)
at compositeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8229:13)
at compositeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8229:13)
at compositeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8229:13)
at compositeLinkFn (http://localhost/plafotrm_2/js/angular/angular.js:8229:13) <div id="chart1" ac-chart="chartType" ac-data="chartData" ac-config="chartConfig" class="ng-isolate-scope">
However, in my index.html, I <link rel="stylesheet" href="css/charts.css" /> and in css/charts.css, I
.chartStyle
{
width: 500px;
height: 500px;
}
and the chart is supposed to go into
<div
data-ac-chart="bar"
data-ac-data="chartData"
data-ac-config="chartConfig"
class="chartStyle" >
</div>
It all looks fine to me, and I copied from a Plunk.
I am sure that I am pulling in the correct CSS File, because if I rename it, I get an error in the developer console. But even with no error about the CSS file, I get the error shown above.
Any ideas, anyone?
[Update]
After applying #SteveCampbell 's comment and answer, there are now no errors in the developer console - alas, there is also no chart on the page :-(
The HTML looks like this
<div data-ac-chart="'bar'" data-ac-data="chartData" data-ac-config="chartConfig" class="chartStyle ng-isolate-scope"></div>
no height or width, so that waitForHeightAndWidth : true is only masking the problem :-(
I think I need to read the docs ...
I have this in the controller ...
$scope.chartConfig = {
title: 'Products',
tooltips: true,
labels: false,
waitForHeightAndWidth : true,
mouseover: function() {},
mouseout: function() {},
click: function() {},
legend: {
display: true,
//could be 'left, right'
position: 'right'
}
};
$scope.chaartData = {
series: ['Sales', 'Income', 'Expense', 'Laptops', 'Keyboards'],
data: [{
x: "Laptops",
y: [100, 500, 0],
tooltip: "this is tooltip"
}, {
x: "Desktops",
y: [300, 100, 100]
}, {
x: "Mobiles",
y: [351]
}, {
x: "Tablets",
y: [54, 0, 879]
}]
};
The issue is not related to CSS. Probably it occurs because the chart element is not initially visible on the first digest cycle, and thus it gets an error when trying to determine the height and width.
The readme on https://github.com/chinmaymk/angular-charts implies that you can set config.waitForHeightAndWidth to true to avoid this problem.

Unable to set value of a textfield because its not in scope

I have a panel where in I have a button in the header which helps me to add two textfields in that panel. Now when I click on this button it takes me to a popup form where the user enters the value of the two textfields it wants and then clicks on save button in the header of this popup panel.
The two textfields are added but the value is not set to the value which is entered in the popup form. I think the problem is with the scope. Kindly look at the following code and tell me how to resolve this issue.
xtype: "panel",
id: 'idFieldpanel',
...
header:{
titlePosition: 0,
items:[{
xtype:'button',
text: 'Add',
handler: function(){
var addidFieldPanel= new Ext.form.Panel({
id: 'newidFieldPanel',
width: 250,
height: 100,
floating: true,
closable : true,
layout : {
type : 'vbox',
align : 'stretch'
},
bodyPadding: 10,
items : [
{
xtype : 'textfield',
id : 'newidFieldname',
fieldLabel : 'Name',
name : 'newidFieldname',
flex : 1,
scope : this
},
{
xtype : 'textfield',
id : 'newidFielddataType',
fieldLabel : 'DataType',
name : 'newidFielddataType',
flex : 1,
scope : this
}
],
header : {
titlePosition : 1,
items : [{
xtype: 'button',
text: 'Save',
handler: function() {
ctr++; //this is used so that the id of the added fields do not match and hence they do not overlap
Ext.getCmp('idFieldpanel').add({
xtype:"container",
layout : {
type : 'hbox',
align : 'stretch'
},
defaults: {
bodyPadding: 10,
margin: '10 0 10 10'
},
items: [
{
xtype : 'textfield',
fieldLabel: 'Name',
id: 'idFieldName' + ctr,
name : 'Data',
margin:'0 10 10 0',
flex : 1,
height : 'auto'
},
{
xtype : 'textfield',
fieldLabel: 'Datatype',
name : 'Type',
id: 'idFielddataType' + ctr,
margin: '0 10 10 0',
flex : 1,
height : 'auto'
}
]
});
Ext.getCmp('idFieldName' + ctr).setValue(Ext.getCmp('newidFieldname').getValue());
Ext.getCmp('idFielddataType' + ctr).setValue(Ext.getCmp('newidFielddataType').getValue());
}
}]
}
})
addidFieldPanel.show();
}
}]
}
There are a few things that can help you out here, but first would be to not bother with tracking unique ID's across your components. Let ExtJS handle that for you. Also, removing the nested handlers will make your code a lot easier to read. I put together this fiddle that shows how you can do that.
By not using ID's you can grab reference to parent/child components with the up/down selectors similar to saveBtn.up('panel').
You can also add a form to your popup for easier selecting. Hope this helps to give you an idea of a better way to leverage the framework.

Sencha EXT JS datagrid scrollbar specifically on column?

We have a gridpanel with columns, that are displaying fine. One column in particular, is a string that can be very large. We want to add a scrollbar to this one column only to accommodate the large wall of text.
Can this be done with Sencha EXT JS? Or if scrollbars can not be done, how about a mouse over to show the whole text in the column?
var secondTab = Ext.create('Ext.grid.Panel', {
columnWidth: 0.60,
xtype: 'gridpanel',
store: standardsResultsStore,
autoheight: true,
columns: [
{
id :'standardName',
text : 'Standard Name',
flex: 1,
sortable : true,
dataIndex: 'standard'
},
{
text : 'Description',
flex : 2,
sortable : true,
dataIndex: 'description_standard'
}
]
});
I did it with CSS, and added tdCls to the specific column
.custom-column .x-grid-cell-inner { white-space:normal; }
--- in tab tdCls: 'custom-column'

Multiple DOJO Data-grids not displaying in Accordian Containers

I have a page with 3 tabs(dijit.layout.TabContainer) and each tab as 2-3 accordians(dijit.layout.AccordionContainer). From a single data store, I am trying to display different grids in each of the accordians.
I am able to display data in a single accordian, but the other grids show up blank, I cant even see headers. If I try to display multiple grids outside the tabs/accordians, it works fine. Not sure what is it that I am missing here.
var jsonStore = new dojo.data.ItemFileWriteStore({ data:{
"identifier": "rowIdentifier",
"label": "gridIdentifier",
"items": [
{
"rowIdentifier": 123,
"gridIdentifier": "labor",
"description": "Project Manager",
"hours": 100.0,
"rate": 100.0
},
{
"rowIdentifier": 234,
"gridIdentifier": "oem",
"description": "Developer",
"hours": 100.0,
"rate": 100.0
}
]
} });
var grid1 = null;
var grid2 = null;
var grid1Layout= [
{ field: "rowIdentifier", width: "auto", name: "Row Identifier",hidden:true },
{ field: "gridIdentifier", width: "auto", name: "Grid Identifier",hidden:true },
{ field: "description", width: "auto", name: "Tier/Description", editable:true },
{ field: "hours", width: "auto", name: "Hours" },
{ field: "rate", width: "auto", name: "Rate <br/>" }
];
grid1 = new dojox.grid.DataGrid({
query: { gridIdentifier: 'labor' },
store: jsonStore,
singleClickEdit: true,
structure: grid1Layout,
rowsPerPage: 6
}, 'grid1Node');
var grid2Layout= [
{ field: "rowIdentifier", width: "auto", name: "Row Identifier",hidden:true },
{ field: "gridIdentifier", width: "auto", name: "Grid Identifier",hidden:true },
{ field: "description", width: "auto", name: "Tier/Description", editable:true },
{ field: "hours", width: "auto", name: "Hours" },
{ field: "rate", width: "auto", name: "Rate <br/>" }
];
grid2 = new dojox.grid.DataGrid({
query: { gridIdentifier: 'oem' },
store: jsonStore,
singleClickEdit: true,
structure: grid2Layout,
rowsPerPage: 6
}, 'grid2Node');
// Call startup, in order to render the grid:
grid1.startup();
grid2.startup();
Below is my HTML
<div style="height: 105px;">
<div dojoType="dijit.layout.TabContainer" style="width: 100%;"
doLayout="false">
<div dojoType="dijit.layout.ContentPane" title="Labor" selected="true">
<div id="LaborAccordian" style="width:auto; height: 300px">
<div dojoType="dijit.layout.AccordionContainer" style="height: 300px;">
<div dojoType="dijit.layout.ContentPane" title="Tab1 Acc1" selected="true">
<div id="grid1Node"></div></div>
<div dojoType="dijit.layout.ContentPane" title="Tab1 Acc2"><div id="SubContractorLaborGridNode"></div></div>
<div dojoType="dijit.layout.ContentPane" title="Tab1 Acc3"><div id="VendedLaborGridNode"></div></div>
</div>
</div>
</div>
<div dojoType="dijit.layout.ContentPane" title="OEM products">
<div id="OEMAccordian" style="width:auto; height: 300px">
<div dojoType="dijit.layout.AccordionContainer" style="height: 300px;">
<div dojoType="dijit.layout.ContentPane" title="Tab2 Acc1"><div id="grid2Node"></div></div>
<div dojoType="dijit.layout.ContentPane" title="Tab2 Acc2" selected="true"></div>
</div>
</div>
</div>
</div>
<!-- end of the div -->
</div>
I have all the appropriate DOJO.requires() in the . Please let me know what I am missing to display the same data store, in different flavors in different accordian containers?
Thanks
SK
From your description, most likely the grid is created successfully, but doesn't show up because the dimension is 0 * 0. The could happen because when the grid is created in a hidden accordion pane, the size of the grid's containing DOM node is actually zero. So when the hidden accordion pane is made visible, the grid size is still zero. This also could happen due to dynamic height and width are specified in the grid's containing node using CSS, e.g. using height or width like 100%. Dynamic height or width may cause problem when calculating the actual height and width.
So my suggestion is to first check the DOM structure using Firebug to see whether the grid is created or not. Most likely you'll see the grid's DOM structure but it doesn't show up because the size is 0 * 0. You can use Firebug to verify it. If this is the case, you can manually instruct the grid to re-calculate its size again by using the resize function. You can use dojo.connect to connect to dijit.layout.AccordionPane's onSelected function and invoke the grid's resize function. Then when a accordion page is selected, the grid inside of it is automatically resized.
I think what Alex Cheng said is correct. And the following changes may slove the problem.
<div id="grid1Node" style="height:100%"></div>
<div id="grid2Node" style="height:100%"></div>
Applying heights for the container of the Grid dom node.
Another solution is to use absolute (not dynamic) height settings, eg:
<div id="grid1Node" style="height:100px"></div>
<div id="grid2Node" style="height:100px"></div>

Resources