Treetable with horizontal scrollbar - webix

Codepen example
Here's a codepen demonstrating a treetable with groups:
https://codepen.io/dharmatech/full/mdWGbox
Screenshot
Screenshot of the above treetable:
The Issue
Only some of the columns are shown; there are many more available. However, note that there is no horizontal scrollbar shown at the bottom to bring the other columns into view.
Is there a way to turn on a horizontal scrollbar?
Approaches I've explored
I've tried each of these:
scrollX: true,
scroll: 'xy',
However, they don't seem to enable a scrollbar.
Treetable Code
Code for the treetable demonstrated above:
{
view: "treetable",
id: "grida",
columns: [
//{ id: "Id", },
//{ id: "Date" },
{
id: "Date",
header: 'Food',
width: 300,
template: function (obj, common) {
if (obj.value) {
return common.treetable(obj, common) + obj.value + `<button onclick=' ( function() { console.log( "${obj.value} - ${obj.Date} - ${obj.Time}" ); } )(); '>Add</button>`;
}
else {
return common.treetable(obj, common) + obj.Food;
}
}
},
// { id: "Time" },
// { id: "Food" },
{ id: "Amount", header: 'Amt', width: 50 },
{ id: "Calories", header: "Cal", width: 50 },
{ id: "Fat", header: "Fat", width: 50 },
{ id: "MonounsaturatedFat", header: "Mono", width: 50 },
{ id: "PolyunsaturatedFat", header: "Poly", width: 50 },
{ id: "Omega3", header: "Om3", width: 50 },
{ id: "Omega6", header: "Om6", width: 50 },
{ id: "SaturatedFat", header: "Sat", width: 50 },
{ id: "TransFat", header: "Trans", width: 50 },
{ id: "Cholesterol", header: "Chole", width: 50 },
{ id: "Carbohydrates", header: "Carb", width: 50 },
{ id: "Fiber", header: "Fib", width: 50 },
{ id: "SolubleFiber", header: "Sol", width: 50 },
{ id: "InsolubleFiber", header: "Ins", width: 50 },
{ id: "Starch", header: "Star", width: 50 },
{ id: "Sugars", header: "Sug", width: 50 },
{ id: "AddedSugars", header: "Add", width: 50 },
{ id: "Protein", header: "Pro", width: 50 },
{ id: "VitaminB1", header: "B1", width: 50 },
{ id: "VitaminB2", header: "B2", width: 50 },
{ id: "VitaminB3", header: "B3", width: 50 },
{ id: "VitaminB5", header: "B5", width: 50 },
{ id: "VitaminB6", header: "B6", width: 50 },
{ id: "VitaminB12", header: "B12", width: 50 },
{ id: "Folate", header: "Fol", width: 50 },
{ id: "VitaminA", header: "A", width: 50 },
{ id: "VitaminC", header: "C", width: 50 },
{ id: "VitaminD", header: "D", width: 50 },
{ id: "VitaminE", header: "E", width: 50 },
{ id: "VitaminK", header: "K", width: 50 },
{ id: "Calcium", header: "Cal", width: 50 },
{ id: "Copper", header: "Cop", width: 50 },
{ id: "Iron", header: "Iron", width: 50 },
{ id: "Magnesium", header: "Mag", width: 50 },
{ id: "Manganese", header: "Mang", width: 50 },
{ id: "Phosphorus", header: "Pho", width: 50 },
{ id: "Potassium", header: "Pot", width: 50 },
{ id: "Selenium", header: "Sel", width: 50 },
{ id: "Sodium", header: "Sod", width: 50 },
{ id: "Zinc", header: "Zinc", width: 50 },
],
scrollX: true,
//scroll: 'xy',
data: data
}
Thanks for any suggestions!
Update 2021-06-11
Aquatic's answer below works well in the codepen. (Thank you Aqauatic!)
However, when I use this treetable in an ASP.NET Core application with the default styling, it looks like this:
Note the following:
The footer and table overlap
The scrollbar is applied to the entire page, instead of just the table.
It appears that the treeview goes out of bounds of the enclosing div.
As suggested by Aquatic, I have a div:
<div style="width: 800px; height: 400px;" id="abc"></div>
Then I reference abc from webix:
webix.ready(function () {
webix.ui({
container: "abc",
Here's a codepen with the CSS copied over from Chrome tools:
https://codepen.io/dharmatech/pen/LYWgyMN
Here's a link to the ASP.NET Core cshtml file on github (as well as the rest of the entire project):
https://github.com/dharmatech/NutritionTrackerRazorPages-2021-05-27-07-32/blob/8207bbd0f6162c8b1a752d8941ea153dd04a1cef/Pages/FoodRecords/IndexWebix.cshtml
If I hardcode the width and height as follows:
{
view: "treetable",
//responsive: true,
id: "grida",
//autowidth: true,
//autoheight: true,
width: 800,
height: 500,
the treeview is properly bounded:
however, it does not resize as the window is resized.
Any suggestions are welcome!

Your code is correct. And TreeTable does show all columns, you just miss the horizontal scroll at bottom of the grid.
To fix the situation, you need to
init UI in container ( currently it is atached to the body ). To do so you need to add container property to the UI configuration
<div id="tree_here">
</div>
webix.ui({
container:"tree_here",
rows: [
be sure to define sizes for the container
#container{
width: 100%;
height: 300px;
}
https://codepen.io/mkozhukh/pen/MWpPwpP

Related

I want to use the "layouts: hanging" feature at all levels, but when I do so, I get overlapping nodes and incorrect lines

I am attempting to do an organization chart using the "layout: handing" feature, and I can use that feature at a single level. However, the moment I want to do a multiple levels, the output is not right.
I have a fiddle at https://jsfiddle.net/markjjordan/Lhewscr0/51/ that exhibits the odd behavior; there are several nodes that are superimposed over another, and the lines and indentations are not correct.
Highcharts.chart('container', {
chart: {
height: 1200,
width: 800,
inverted: true
},
title: {
text: 'Highcharts Org Chart'
},
series: [{
type: 'organization',
name: 'Highsoft',
keys: ['from', 'to'],
data: [
['001', '001.001'],
['001.001', '001.001.005'],
['001.001', '001.001.001'],
['001.001', '001.001.002'],
['001.001', '001.001.003'],
['001.001', '001.001.004'],
['001.001.001', '001.001.001.001'],
['001.001.001', '001.001.001.002'],
['001.001.001', '001.001.001.003'],
['001.001.001', '001.001.001.004'],
//['CTO', 'Product'],
//['CTO', 'Web'],
//['CSO', 'Sales'],
// ['CMO', 'Market']
],
nodes: [{
id: '001',
layout: 'hanging',
//column: 1,
width: 300
}, {
id: '001.001',
layout: 'hanging',
//column: 2,
width: 300
}, {
id: '001.001.005',
layout: 'hanging',
//column: 3,
width: 300
}, {
id: '001.001.001',
layout: 'hanging',
//column: 4,
width: 300
}, {
id: '001.001.002',
layout: 'hanging',
//column: 5,
width: 300
}, {
id: '001.001.003',
layout: 'hanging',
//column: 6,
width: 300
}, {
id: '001.001.004',
layout: 'hanging',
//column: 7,
width: 300
},
{
id: '001.001.001.001',
layout: 'hanging',
//column: 8,
width: 300
}, {
id: '001.001.001.002',
layout: 'hanging',
//column: 9,
width: 300
}, {
id: '001.001.001.003',
layout: 'hanging',
//column: 10,
width: 300
}, {
id: '001.001.001.004',
layout: 'hanging',
//column: 11,
width: 300
}
//}
//, {
// id: 'Product',
// name: 'Product developers'
//}, {
// id: 'Web',
// name: 'General tech',
// description: 'Web developers, sys admin'
//}, {
// id: 'Sales',
// name: 'Sales team'
//}, {
// id: 'Market',
// name: 'Marketing team'
]
,
colorByPoint: false,
color: '#007ad0',
dataLabels: {
color: 'white'
},
borderColor: 'white',
nodeWidth: 65
}],
tooltip: {
outside: true
},
exporting: {
allowHTML: true,
sourceWidth: 800,
sourceHeight: 600
}
});
I am expecting the output to look similar to the following, with of course course the appropriate lines:
https://1drv.ms/u/s!AlXtfnUUrEyMzJ8pVtI0oOhqhXFUKw?e=10b0l3
You can achieve what you expect manually setting column index and offset for each node. Check demo and code posted below:
Code:
nodes: [{
id: '001',
width: 200,
offset: '-70%'
}, {
id: '001.001',
offset: '-50%',
width: 200,
}, {
id: '001.001.005',
column: 2,
width: 200,
offset: '-30%',
}, {
id: '001.001.001',
column: 3,
offset: '-30%',
width: 200
}, {
id: '001.001.002',
column: 8,
offset: '-30%',
width: 200
}, {
id: '001.001.003',
column: 9,
offset: '-30%',
width: 200
}, {
id: '001.001.004',
column: 10,
offset: '-30%',
width: 200
},
{
id: '001.001.001.001',
column: 4,
width: 200,
offset: '-5%',
}, {
id: '001.001.001.002',
column: 5,
width: 200,
offset: '-5%',
}, {
id: '001.001.001.003',
column: 6,
width: 200,
offset: '-5%',
}, {
id: '001.001.001.004',
column: 7,
width: 200,
offset: '-5%',
}
]
Demo:
https://jsfiddle.net/BlackLabel/jxp7nLkb/2/
https://jsfiddle.net/BlackLabel/s0oykx29/
API reference:
https://api.highcharts.com/highcharts/series.organization.nodes.column
https://api.highcharts.com/highcharts/series.organization.nodes.offset

Align titles for multiple axis in Highstock

I have 4 axis in a Highstock chart:
var p0 = [
[1538341200000,110.91],
[1538427600000,126.01],
[1538514000000,129.54],
[1538600400000,125.54]];
var p1 = [
[1538341200000,113.14],
[1538427600000,129.48],
[1538514000000,132.28],
[1538600400000,129.53],];
var t0 = [
[1538341200000,29.25],
[1538427600000,37.28],
[1538514000000,36.1],
[1538600400000,36.17],];
var t1 = [
[1538341200000,29.67],
[1538427600000,37.53],
[1538514000000,37.26],
[1538600400000,37.9],];
Highcharts.stockChart('container', {
chart: {
renderTo: "container"
},
title: {
text: "Sample test",
align: "center",
y: 14
},
legend: {
enabled: true,
align: "center",
verticalAlign: "top",
y: 40
},
xAxis: {
ordinal: false
},
yAxis: [
{
left: "-100%",
height: "18%",
top: "7%"
},
{
left: "-100%",
height: "18%",
top: "32%"
},
{
left: "-100%",
height: "18%",
top: "57%"
},
{
left: "-100%",
height: "18%",
top: "82%"
}
],
series: [
{
name: "Pressure 3",
data: p0,
yAxis: 0
},
{
name: "Pressure 4",
data: p1,
yAxis: 1
},
{
name: "Temperature 3",
data: t0,
yAxis: 2
},
{
name: "Temperature 4",
data: t1,
yAxis: 3
}
]
});
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<div id="container" style="width: 600px; height: 600px;"></div>
Now, I want to add titles to every axis on the top left corner, like this:
var p0 = [
[1538341200000,110.91],
[1538427600000,126.01],
[1538514000000,129.54],
[1538600400000,125.54]];
var p1 = [
[1538341200000,113.14],
[1538427600000,129.48],
[1538514000000,132.28],
[1538600400000,129.53],];
var t0 = [
[1538341200000,29.25],
[1538427600000,37.28],
[1538514000000,36.1],
[1538600400000,36.17],];
var t1 = [
[1538341200000,29.67],
[1538427600000,37.53],
[1538514000000,37.26],
[1538600400000,37.9],];
Highcharts.stockChart('container', {
chart: {
renderTo: "container"
},
title: {
text: "Sample test",
align: "center",
y: 14
},
legend: {
enabled: true,
align: "center",
verticalAlign: "top",
y: 40
},
xAxis: {
ordinal: false
},
yAxis: [
{
title: {
text: "Pressure 3",
rotation: 0,
y: -10
},
left: "-101%",
height: "18%",
top: "7%"
},
{
title: {
text: "Pressure 4",
rotation: 0,
y: -10
},
left: "-101%",
height: "18%",
top: "32%"
},
{
title: {
text: "Temperature 3",
rotation: 0,
y: -10
},
left: "-101%",
height: "18%",
top: "57%"
},
{
title: {
text: "Temperature 4",
rotation: 0,
y: -10
},
left: "-101%",
height: "18%",
top: "82%"
}
],
series: [
{
name: "Pressure 3",
data: p0,
yAxis: 0
},
{
name: "Pressure 4",
data: p1,
yAxis: 1
},
{
name: "Temperature 3",
data: t0,
yAxis: 2
},
{
name: "Temperature 4",
data: t1,
yAxis: 3
}
]
});
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<div id="container" style="min-width: 400px; height: 600px;"></div>
As you can see every title breaks the next one adding some margin and "pushing" them to the right.
This is the expected result:
I tried many highstock properties and css styles to make them float to avoid them to push themselves, but nothing is working.
How to avoid this problem?
What you're trying to achieve is not a default behavior for axis title. The easiest way to plot titles as you expect is to make custom titles using Highcharts SVG renderer.
Each yAxis has properties top and left that we can use to plot custom titles at proper positions. Notice, that navigator is just an additional series so yAxis array will have one more element than you defined. Titles created by renderer are Highcharts.SVGElement. Each time the chart will be rendered you have to destroy the old ones and rendered them again (in new positions):
var titlesColl = [],
titles = [
"Pressure 3",
"Pressure 4",
"Temperature 3",
"Temperature 4"
];
chart: {
events: {
render: function() {
var chart = this,
yaxisColl = chart.yAxis,
offsetY = -4,
axis,
title,
i;
if (titlesColl.length) {
titlesColl.forEach(function(elem) {
elem.destroy();
});
titlesColl.length = 0;
}
for (i = 0; i < yaxisColl.length - 1; i++) {
axis = yaxisColl[i];
title = chart.renderer
.text(titles[i], axis.left, axis.top + offsetY)
.css({
'font-size': '10px'
})
.add();
titlesColl.push(title);
}
}
}
}
chart.events.render documentation
Demo:
https://jsfiddle.net/wchmiel/sxnyLhfb/

how can i do to not lose a filter in a jqxGrid when a change the next page? i'm using the filters from my dataAdapter

i have a problem, i use this control is a jqxGrid, this is:
function initGridUsuarios() {
// campos y adaptador
var fields = [
{ name: "NoEmpleado", type: "int" },
{ name: "Nombre", type: "string" },
{ name: "Departamento", type: "string" }
],
dataAdapter = utils.generateGridAdapter(gridEmpleados, "GestionPaqueteInfo", "ObtenerGridUsuarios", fields, getGridFilters);
gridEmpleados.jqxGrid({
width: 900,
height: 400,
theme: tema,
columnsresize: true,
pageable: true,
altrows: true,
virtualmode: true,
rendergridrows: function () {
return dataAdapter.records;
},
localization: utils.getIdiomaGrid(),
source: dataAdapter,
columns: [
{ text: "Id", dataField: "Id", columngroup: "Titulo", width: 100, hidden: true },
{ text: "Número de Empleado", dataField: "NoEmpleado", columngroup: "Titulo", width: 150 },
{ text: "Nombre", dataField: "Nombre", columngroup: "Titulo", width: 250 },
{ text: "Departamento", dataField: "Departamento", columngroup: "Titulo", width: 350 },
{
text: "Crear paquete info", datafield: "Crear", columngroup: "Titulo", columntype: "button", width: 150, cellsrenderer: function () {
return "Crear";
}, buttonclick: function (clickRow) {
crear();
}
},
],
columngroups: [
{ text: "Busqueda de Empleados para creación de paquete inventario informática", align: "center", name: "Titulo" }
]
});
}
actually it loose the filter, when i change the page, what can i do to not lose the filter?
:$ sorry my english is not really good :$:$

issue in showing pager after reloading the jqxgrid data on click event

I am trying to reload the grid on click event. Here is my code for grid
var source = {
datatype: "json",
datafields: [
{ name: 'sno' },
{ name: 'bid' },
{ name: 'city' },
{ name: 'booking_date' },
{ name: 'amount' },
{ name: 'customer_contact' },
{ name: 'user_name' },
{ name: 'trip_type' },
{ name: 'comments' },
{ name: 'action' },
],
cache: false,
url: 'order_details.php?flag=2&start_date='+start_date_param+'&end_date='+end_date_param,
data: {
pagesize:50
},
root: 'Rows',
//sortcolumn: 'area',
// sortdirection: 'asc',
beforeprocessing: function (data) {
source.totalrecords = data[0].TotalRows;
}
};
dataadapter = new $.jqx.dataAdapter(source);
// initialize jqxGrid
$("#jqxgrid").jqxGrid(
{
width: 1100,
source: dataadapter,
theme: 'classic',
autoheight: true,
pageable: true,
pagesize:50,
enablebrowserselection: true,
selectionmode: 'singlecell',
//sortable:true,
virtualmode: true,
rendergridrows: function (params) {
return params.data;
},
columns:
[
{ text: 'No', datafield: 'sno', width: 30 },
{ text: 'Booking Id', datafield: 'bid', width: 90, align: 'center',cellsAlign: 'center' },
{ text: 'City', datafield: 'city', width: 170 },
{ text: 'Car Book Date', datafield: 'booking_date', width: 100, align: 'center',cellsAlign: 'center' },
{ text: 'Amount', datafield: 'amount', width: 60, align: 'right',cellsAlign: 'right' },
{ text: 'Customer Contact', datafield: 'customer_contact', width: 205 },
{ text: 'User Name', datafield: 'user_name', width: 125 },
{ text: 'Trip Type', datafield: 'trip_type', width: 160},
{ text: 'Comments', datafield: 'comments', width: 80, align: 'center',cellsAlign: 'center'},
{ text: 'Action', datafield: 'action', width: 80, align: 'center',cellsAlign: 'center'},
]
});
// event handling on select of date range and click on button show
$("#btn_show").on("click", function (e) {
e.preventDefault();
var start_date_param = $("#start_date").val();
var end_date_param = $("#end_date").val();
source.url = 'order_details.php?flag=2&start_date='+start_date_param+'&end_date='+end_date_param;
dataadapter.dataBind();
});
On click of button "btn_show", I could get the data from page 0, but if I am on page 4, then after click event, my grid pager is remains on page 4 only and data is display for page 0.If I click on next page, then it jumps from page 0 to next page i.e page 5.
Why jqxgrid is not resetting its recordedstartindex and recordedendindex values on dataadapter.dataBind() call after click event?
Do I need to use any other function to reload my complete grid??
I think that the following:
$("#jqxgrid").jqxGrid('gotopage', 0);
should replace
dataadapter.dataBind();
In your code.

jqGrid the correct way to expand column width

I am attempting to widen my columns here with the colModel property of jqGrid. when I do this, my table data disappears. Does any body know why this would happen. Before and after pictures will be below. As well as the jquery code that I use.
Here is an example of it working.
Here is an example after I have attempted to widen the columns
jQuery(document).ready(function () {
ShowMessage();
tableToGrid("#table1", {
height: '200',
shrinkToFit: false,
autowidth: true,
colNames: ['Edit',
'MRN',
'Hospital Fin',
'First Name',
'Last Name',
'Date of birth',
'Completed Pathway',
'Completed Pathway Reason',
'PCP Appointment',
'Specialist Appointment',
'Admit Date',
'Discharge Date',
'Discharge Disposition',
'Discharge To',
'Discharge Advocate Call',
'Home Healthcare',
'Safe Landing Accepted',
'PCP Name',
'PCP Phone',
'PCP Appointment Location',
'Specialist Name',
'Specialist Phone',
'Specialist Appointment Location',
'Comments',
'Patient Room',
'Phone',
'Payor',
'MRN Type'
],
colModel: [{ name: 'Edit', width: 55 },
{ name: 'MRN', width: 55 },
{ name: 'HospitalFin', width: 85 },
{ name: 'FirstName', width: 85 },
{ name: 'LastName', width: 85 },
{ name: 'Dateofbirth', width: 85 },
{ name: 'CompletedPathway', width: 145 },
{ name: 'CompletedPathwayReason', width: 165 },
{ name: 'PCPAppointment', width: 145 },
{ name: 'SpecialistAppointment', width: 165 },
{ name: 'AdmitDate', width: 55 },
{ name: 'DischargeDate', width: 80 },
{ name: 'DischargeDisposition', width: 180 },
{ name: 'DischargeTo', width: 55 },
{ name: 'DischargeAdvocateCall', width: 165 },
{ name: 'HomeHealthCareAccepted', width: 165 },
{ name: 'SafeLandingAccepted', width: 165 },
{ name: 'PCPName', width: 55 },
{ name: 'PCPPhone', width: 55 },
{ name: 'PCPAppointmentLocation', width: 165 },
{ name: 'SpecialistName', width: 185 },
{ name: 'SpecialistPhone', width: 185 },
{ name: 'SpecialistAppointmentLocation', width: 185 },
{ name: 'Comments', width: 55 },
{ name: 'PatientRoom', width: 85 },
{ name: 'Phone', width: 85 },
{ name: 'Payor', width: 85 },
{ name: 'MRNType', width: 85 }
]
});
$(window).bind('resize', function () {
$("#table1").fluidGrid({ example: "#tempplateInfo", offset: -10 });
$("#table1 tbody").sortable("destroy");
});
(function ($) {
jQuery.jgrid.fluid = {
fluidGrid: function (options) {
var grid = $(this);
var settings = $.extend({
example: grid.closest('.ui-jqgrid').parent(), offset: 0
},
options || {});
var width = $(settings.example).innerWidth() + settings.offset; grid.setGridWidth(width);
}
}
})
(jQuery);
jQuery.fn.extend({ fluidGrid: jQuery.jgrid.fluid.fluidGrid });
var $grid = $('#table1'),
hdiv = $grid[0].grid.hDiv,
$columnHeaders = $("thead tr.ui-jqgrid-labels th", hdiv)
$columnHeaders.unbind('mouseenter');
$columnHeaders.unbind('mouseleave');
Comment out the columnModel section to get an idea of what I had when it was working. Should the colModel name property be equal to the th for instance? What is the word good fellows. I am getting inconsitent results.

Resources