I can't find proper answer for two questions concerning grid (lot of different answers, no one good):
how can I center texts in grid cells vertically;
how can I display vertical lines as well as horizontal.
Be so kind as to prompt me, please.
Apply custom css to your grid. Something like this:
#GridId div.x-grid-cell-inner { text-align: center; }
To center the text in the center of the column use the align property, this way align: 'center'. Notice that the email column is centralized.
In the case of vertical lines it is more complicated.
ExtJS has a setting to show the lines of the column columnLines: true, but doesn’t have a property to show line rows. So we should use a CSS class and set the bottom border, in this way border-bottom-color: red !important;
To test in other versions of ExtJS access this fiddle.
var Grid1Store = new Ext.data.JsonStore({
fields: ['id', 'name', 'email'],
autoLoad: true,
data: [{
"id": 1,
"name": "John Smith",
"email": "jsmith#example.com"
}, {
"id": 2,
"name": "Anna Smith",
"email": "asmith#example.com"
}, {
"id": 3,
"name": "Peter Smith",
"email": "psmith#example.com"
}, {
"id": 4,
"name": "Tom Smith",
"email": "tsmith#example.com"
}, {
"id": 5,
"name": "Andy Smith",
"email": "asmith#example.com"
}, {
"id": 6,
"name": "Nick Smith",
"email": "nsmith#example.com"
}]
});
var onReadyFunction = function() {
var grid = new Ext.grid.GridPanel({
renderTo: Ext.getBody(),
frame: true,
title: 'Example',
width: 450,
height: 200,
store: Grid1Store,
columns: [{
header: "Id",
dataIndex: 'id',
width: '50px'
}, {
header: "Name",
dataIndex: 'name',
width: '150px'
}, {
header: "Email",
dataIndex: 'email',
width: '200px',
align: 'center'
}]
});
}
Ext.onReady(onReadyFunction);
.x-grid-cell {
border-bottom-color: red !important;
}
<script src="http://cdn.sencha.com/ext/gpl/4.2.0/ext-all.js"></script>
<link type="text/css" rel="stylesheet" href="http://cdn.sencha.com/ext/gpl/4.2.0/resources/css/ext-all.css")/>
Related
I have a Highcharts bar graph. Each point has a group of results, however the first and last element are being cropped. How can I extend the x-axis so every bar is shown?
In the image below each group has the same results so you can see the N and P are dropped from the first group and S and Mg from the last grouping.
The data is coming from a database, so i don't know how many groups there will be, or what range (so simply adding a day to each end is not sufficient, the overlap could be larger or smaller)
const conf = {
chart: {
type: "column",
animation: false,
marginRight: 10,
dateFormat: "dd/mm/YYYY"
},
title: {
text: "Spread Events"
},
xAxis: {
type: "datetime",
tickPixelInterval: 50
},
yAxis: {
title: {
text: "Spread"
},
plotLines: [
{
value: 0,
width: 1,
color: "#808080"
}
]
},
legend: {
enabled: true
},
exporting: {
enabled: false
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: this.state.graphData
};
and this is the graphData from the example
[
{
"name": "N",
"data": [[1559669642443, 300], [1559343600000, 300], [1559257200000, 300]]
},
{
"name": "P",
"data": [[1559669642443, 160], [1559343600000, 160], [1559257200000, 160]]
},
{
"name": "K",
"data": [[1559669642443, 470], [1559343600000, 470], [1559257200000, 470]]
},
{
"name": "S",
"data": [[1559669642443, 120], [1559343600000, 120], [1559257200000, 120]]
},
{
"name": "Mg",
"data": [[1559669642443, 90], [1559343600000, 90], [1559257200000, 90]]
}
]
You have Highcharts error #15 in a console, which means that your data is not sorted. Highcharts requires sorted data in ascending X order:
series: [{
...,
data: [
[1559257200000, 300],
[1559343600000, 300],
[1559669642443, 300]
]
}, ...
]
Live demo: http://jsfiddle.net/BlackLabel/y2rzd65m/
In my extjs 6.2 project I am trying to create columns for my grid from the store which is dynamic.
My grid is created on view page
title: 'Data Viewer',
xtype: 'grid',
itemId: 'gridDataViewerId',
bind: {
store: '{storeData}'
},
ui: 'featuredpanel-framed',
cls: 'custom-grid',
margin: '5',
//frame: false,
//forceFit: true,
//height: '100%',
flex: 1,
plugins: [{
ptype: 'gridexporter'
}]
Once the store is loaded I am trying to create the columns and populate the data but its not working. Any ideas what I am doing wrong?
this.storeData.load({
url: x.util.GlobalVar.urlData_getData,
params: {
cid: cid,
email: localStorage.getItem('username'),
dateStart: targetStart,
dateEnd: targetEnd,
filename: targetFile
},
callback: function (response, opts) {
debugger;
var columnModel = me.storeData.data.items;
me.myGrid.reconfigure(me.storeData, columnModel);
}
});
I think my problem is creating the column array from my store. If I try do do it manually it works... but I need to do it dynamically.
Use the store's metachange listener. Something like:
myStore.on('metachange', function(store, meta){
myGrid.reconfigure(store, meta.columns);
}
Where the store data looks something like this:
{
"records": [{
"id": 74474,
"name": "blah",
"age": 5
},{
"id": 74475,
"name": "asfdblah",
"age": 35
}],
"totalRecords": 2,
"metaData": {
"fields": [{
"name": "name"
},{
"name": "age",
"type": "number"
}],
"columns": [{
"text": "Name",
"dataIndex": "name",
"width": 150
},
{
"text": "Age",
"dataIndex": "age"
}],
},
"success": true
}
I am trying to make some of checkboxes checked and disabled in jqxTreeGrid in below code:
$("#treegrid_portfolio").jqxTreeGrid(
{
source: dataAdapter,
pageable: true,
pagerMode: 'advanced',
pageSizeMode: 'root',
pageSize: 5,
pageSizeOptions: ['1', '2', '3', '5', '10'],
columnsResize: true,
sortable: true,
filterable: true,
theme: "custom",
filterMode: 'advanced',
altRows: false,
checkboxes: true,
columnsReorder: true,
hierarchicalCheckboxes: true,
width: getWidth("TreeGrid"),
/*width: "100%",*/
ready: function () {
$("#treegrid_portfolio").jqxTreeGrid('expandRow', '1');
$("#treegrid_portfolio").jqxTreeGrid('expandRow', '2');
}
,
columns: [
{
text: "ID", dataField: "formattedID", width: 120, pinned: true, cellclassname: "requestIdCls", resizable: false
}
,
{
text: '', datafield: 'alert', cellsrenderer: linkrendererAlert, width: 60, pinned: true, cellclassname: "alert_column", cellsAlign: 'center', filterable: false, resizable: false
}
,
{
text: "Portfolio Items Name", dataField: "PortfolioItem_Name", width: 200
}
,
{
text: "Agile Central Project Name", dataField: "AC_ProjectName", width: 200
}
]
}
);
Is it possible to make the same on grid ready function. I have done some research on the jqwidget. But didn't got any solution or clues. Please help me any one.
You need to make below changes also just put id attribute for each of your column data .Then put the id for selecting checkbox to set true.
follow this link i have get a fiddle for you Invoke the uncheckRow method.
var data = [{
"id": "1",
"name": "Corporate Headquarters",
"budget": "1230000",
"location": "Las Vegas",
"children": [{
"id": "2",
"name": "Finance Division",
"budget": "423000",
"location": "San Antonio",
"children": [{
"id": "3",
"name": "Accounting Department",
"budget": "113000",
"location": "San Antonio"
}, {
"id": "4",
"name": "Investment Department",
"budget": "310000",
"location": "San Antonio",
children: [{
"id": "5",
"name": "Banking Office",
"budget": "240000",
"location": "San Antonio"
}, {
"id": "6",
"name": "Bonds Office",
"budget": "70000",
"location": "San Antonio"
}, ]
}]
}, {
"id": "7",
"name": "Operations Division",
"budget": "600000",
"location": "Miami",
"children": [{
"id": "8",
"name": "Manufacturing Department",
"budget": "300000",
"location": "Miami"
}, {
"id": "9",
"name": "Public Relations Department",
"budget": "200000",
"location": "Miami"
}, {
"id": "10",
"name": "Sales Department",
"budget": "100000",
"location": "Miami"
}]
}, {
"id": "11",
"name": "Research Division",
"budget": "200000",
"location": "Boston"
}]
}];
var source = {
dataType: "json",
dataFields: [{
name: "name",
type: "string"
}, {
name: "budget",
type: "number"
}, {
name: "id",
type: "number"
}, {
name: "children",
type: "array"
}, {
name: "location",
type: "string"
}],
hierarchy: {
root: "children"
},
localData: data,
id: "id"
};
var dataAdapter = new $.jqx.dataAdapter(source, {
loadComplete: function () {
}
});
// create jqxTreeGrid.
$("#treeGrid").jqxTreeGrid({
source: dataAdapter,
altRows: true,
width: 680,
theme:'energyblue',
checkboxes: true,
ready: function () {
$("#treeGrid").jqxTreeGrid('expandRow', '1');
$("#treeGrid").jqxTreeGrid('expandRow', '2');
},
columns: [{
text: "Name",
align: "center",
dataField: "name",
width: 300
}, {
text: "Budget",
cellsAlign: "center",
align: "center",
dataField: "budget",
cellsFormat: "c2",
width: 250
}, {
text: "Location",
dataField: "location",
cellsAlign: "center",
align: "center"
}]
});
$("#jqxbutton").jqxButton({
theme: 'energyblue',
height: 30
});
$("#treeGrid").jqxTreeGrid('checkRow',2);
The last line of code
$("#treeGrid").jqxTreeGrid('checkRow',2); is reason to check the checkbox true while loading.
Please makesure if any help required.Hope it may help.
To check rows on grid ready function use checkRow method, and lockRow will disable editing of the row and give the row gray style.
3 or 8 are Unique ID which identifies the row Id (data field in data source).
ready: function () {
$("#treeGrid").jqxTreeGrid('checkRow', '3');
$("#treeGrid").jqxTreeGrid('lockRow', '3');
$("#treeGrid").jqxTreeGrid('checkRow', '8');
$("#treeGrid").jqxTreeGrid('lockRow', '8');
},
To disable checkboxes you can use rowUncheck event to prevent uncheck by checking the row again.
$('#treeGrid').on('rowUncheck', function (event) {
$("#treeGrid").jqxTreeGrid('checkRow', '3');
$("#treeGrid").jqxTreeGrid('checkRow', '8');
});
$("#treeGrid").jqxTreeGrid({
// ......
});
I am using Dojo 1.10 to create an ItemFileReadStore object using AMD. Though the console did not report any error while creating the store, I could see from the debugger that the store.data is null. I tried the same code on my browser console (both chrome and firefox) but there too its the same issue (store data is null). Could someone please help me figure out if am I missing something?
require(["dojo/ready",
"dojo/on",
"dijit/registry",
"dojo/data/ItemFileReadStore"
], function(ready, on, registry, ItemFileReadStore) {
var resultTablecolumns = [{
label: 'ID',
attr: 'id',
sortable: true,
sorted: 'ascending',
width: 60,
vAlignment: "middle",
alignment: "right"
}, {
label: 'Hop',
attr: 'hop',
sortable: true,
sorted: 'ascending',
width: 100,
vAlignment: "middle",
alignment: "right"
}, {
label: 'Role',
attr: 'role',
sortable: true,
sorted: 'ascending',
width: 100,
vAlignment: "middle",
alignment: "right"
}, {
label: 'Status',
attr: 'status',
sortable: true,
sorted: 'ascending',
width: 100,
vAlignment: "middle",
alignment: "right"
}];
var storeItems = {
"identifier": "id",
"items": [{
"id": "1",
"hop": "first",
"role": "classification",
"status": ""
}, {
"id": "2",
"hop": "second",
"role": "propagation",
"status": "info"
}, {
"id": "3",
"hop": "third",
"role": "propagation",
"status": "warning"
}, {
"id": "4",
"hop": "fourth",
"role": "propagation",
"status": "error"
}, {
"id": "5",
"hop": "fifth",
"role": "enforcement",
"status": ""
}]
};
var resultTableStore = new ItemFileReadStore({
data: storeItems
});
console.log("resultTableStore === ", resultTableStore);
});
Can you show us your HTML?
Here is a working jsFiddle.
require(["dojo/data/ItemFileReadStore","dojo/dom", "dojo/domReady!"], function(ItemFileReadStore, dom ){
var storeItems = {
"identifier": "id",
"items": [{
"id": "1",
"hop": "first",
"role": "classification",
"status": ""
}]
};
var store = new ItemFileReadStore({data: storeItems});
console.log("ItemFileReadStore",ItemFileReadStore);
dom.byId('store').innerHTML = store ;
});
There is a new kid on the block which replaces the above store i.e dstore. Try it.
Ok, I figured out with the help of a co-worker.
I am actually creating a ItemFileReadStore and using it in constructing a data-grid. The grid was not showing up because its parent was hid when it got created, and hence got its width set to zero.
I understood from him that the data argument is processed on first fetch and used to populate internal structures. It is then nulled out as it is no longer used.
So in this case, what was happening is ItemFileReadStore's data argument was processed on first-fetch while creating the grid and then got set to null.
This is just a section of my JSON Data string as it is quite extensive...
{
"total": 2,
"page": 1,
"records": 15,
"rows": [
{
"id": 2148,
"cell": {
"MRN": "840134833",
"Hospital_Fin": "987141516",
"First_Name": "YELLOW",
"Last_Name": "CRAYON",
"Date_of_birth": "/Date(1253160000000)/"}
}
]}
And this would be how I set up my jqGrid...
$(document).ready(function () {
jQuery("#frTable").jqGrid ({
cmTemplate: { sortable: false },
caption: '#TempData["POPNAME"]' + ' Population',
datatype: 'json',
mtype: 'GET',
url: '#Url.Action("GetAjaxPagedGridData", "Encounters", new { popId = TempData["POPULATIONID"] })',//'/Encounters/GetAjaxPagedGridData/'+ '',
pager: '#pager',
loadonce: true,
height: 450,
gridview: true,
viewrecords: true,
rowNum: 15,
shrinkToFit: false,
autowidth: true,
colNames: [
'MRN',
'Hospital Fin',
'First Name',
'Last Name',
'Date of birth'
colModel: [
{ name: 'MRN', width: 125, align: 'left' },
{ name: 'Hospital_Fin', width: 145, align: 'left' },
{ name: 'First_Name', width: 115, align: 'left' },
{ name: 'Last_Name', width: 115, align: 'left' },
{ name: 'Date_of_birth', width: 145, align: 'left', formatter:'date', formatoptions: {newformat: 'm/d/Y'}}]
Now...
I look through JSfiddle and I do get the Json string back in the right format. In fact, That is how I was able to copy and paste to this fine website. So what am I missing? It looks like everything should be about right?
UPDATE
Do my col models and the names of my columns in my cell have to match up 100 percent? Maybe that would be someplace to take a look?
You use wrong format of JSON data. Compare your data with the data expected by jqGrid described in the documentation. To fix JSON data you can change it to for example the following
{
"total": 2,
"page": 1,
"records": 15,
"rows": [
{
"id": 2148,
"MRN": "840134833",
"Hospital_Fin": "987141516",
"First_Name": "YELLOW",
"Last_Name": "CRAYON",
"Date_of_birth": "/Date(1253160000000)/"
}
]
}
You need include additionally jsonReader: {repeatitems: false} in the list of jqGrid options.