Restrict number of characters in JqxGrid - jqxgrid

I have a jqxGrid as below and i want to restrict number of characters in jqxGrid.
columns : [ {
text :
‘Type’,datafield : ‘type’, width : 150, align : ‘center’,cellsalign : ‘left’, editable : false
}, {
text :
‘Phase’,datafield : ‘phase’, width : 150, align : ‘center’,cellsalign : ‘left’, editable : false
},{
text :
‘Phase Description’,datafield : ‘phaseDescription’, width : 150, align : ‘center’,cellsalign : ‘left’, editable : false
},{
text :
‘Custom Phase’, datafield : ‘customPhase’, width : 150, align : ‘center’, cellsalign : ‘left’
}
for the column ‘Custom Phase’ i need to restrict user entry to 10 characters. How to achieve it?

For this, you have to use jqwidget validation and include the file jqxvalidator.js in your view file and use this code in column:
columns : [ {
text :
‘Type’,datafield : ‘type’, width : 150, align : ‘center’,cellsalign : ‘left’, editable : false
}, {
text :
‘Phase’,datafield : ‘phase’, width : 150, align : ‘center’,cellsalign : ‘left’, editable : false
},{
text :
‘Phase Description’,datafield : ‘phaseDescription’, width : 150, align : ‘center’,cellsalign : ‘left’, editable : false
},{
text :
‘Custom Phase’, datafield : ‘customPhase’, width : 150, align : ‘center’, cellsalign : ‘left’,
validation: function (cell, value)
{
if (value.length > 10) {
return { result: false, message: "character should be maximum 10" };
}
return true;
}
}

This demo use of the column's "validation" function: cellediting.htm.
validation: function(cell, value)
{
if (value.toString().length > 10)
{
return { result: false, message: "entered text should be less than 10 characters"}
}
return true;
}
toString() is required because the value could be Number or Date object.

Related

Dynamic cell color in jspdf autoTable?

Is it possible to define the cell color with a nested property of the object mapped to the table ?
The JSON structure of the objects is :
objects: [
{
"agent": "agent_1",
"days": {
day_0: {
"code": "ABC",
"color": "#0062cc"
},
day_1: {
"code": "DEF",
"color": "#a09494b2"
}
},
{
[...]
}
]
I have a table defined like this :
let columns = [
{title: "Agent", dataKey: "agent"},
{title: "january 1st", dataKey: "day_0"},
{title: "january 2nd", dataKey: "day_1"}]
let rows = [
{agent: "agent_1", day_0: "ABC", day_1: "DEF"},
[...]
]
All that works fine. But I'd like to set the color of each day cell dynamically, set with the color code of the corresponding object. Something like :
createdCell: function(cell, data) {
{
cell.styles.fillColor = "day_0.color";
}
}
But I can't figure how to pass the data to the table. Is it possible ? Can displayProperty help in any way ?
EDIT: In this case it was that v2.3.4 of jspdf-autotable was needed
Based on our comments discussion I think I understood your problem. You can try something like this (with the hexToRgb function from here)
let columns = [{
title: "Agent",
dataKey: "agent"
},
{
title: "january 1st",
dataKey: "day_0"
},
{
title: "january 2nd",
dataKey: "day_1"
}
]
let objects = [{
agent: "agent_1",
day_0: {
"code": "ABC",
"color": "#00ff00"
},
day_1: {
"code": "DEF",
"color": "#ff0000"
}
// etc
}];
let doc = jsPDF()
doc.autoTable(columns, objects, {
createdCell: function(cell, data) {
let hex = cell.raw.color
if (hex) {
let rgb = hexToRgb(hex)
cell.styles.fillColor = rgb;
cell.text = cell.raw.code
}
}
});
doc.save('jhg.pdf')
function hexToRgb(hex) {
var bigint = parseInt(hex.replace('#', ''), 16);
var r = (bigint >> 16) & 255;
var g = (bigint >> 8) & 255;
var b = bigint & 255;
return [r, g, b];
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.4.1/jspdf.debug.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/2.3.4/jspdf.plugin.autotable.js"></script>
I just leave the answer here just in case anyone needs it.
We can use the didParseCell hook.
doc.autoTable({
head: [[..., color]],
body: [[..., #ffffff], [..., #ff0000]], // pass hexa value to the cell
didParseCell: function (HookData) {
if (HookData.cell == undefined)
return;
// find cell taht contains the hexa value
// the change the fillColor property
// and set the cell value to empty
var color = HookData.cell.text[0];
if (color.match(/^#[a-fA-F0-9]{3}([a-fA-F0-9]{3})/g) != null) {
HookData.cell.styles.fillColor = hexToRgb(color);
HookData.cell.text = [];
}
}
});
Code to convert hexa to RGB:
hexToRgb(hex) {
var bigint = parseInt(hex.replace('#', ''), 16);
var r = (bigint >> 16) & 255;
var g = (bigint >> 8) & 255;
var b = bigint & 255;
return [r, g, b];
}
Package version:
jspdf : 2.5.1
jspdf-autotable :3.5.25

Highcharts Sunburst levels radius

I'm making a sunburst with Highcharts .NET,
This is how i setup the chart:
Highcharts higcharts = new Highcharts
{
Chart = new Chart
{
Type = ChartType.Sunburst,
Width = 700,
Height = 700
},
Title = new Title
{
Text = "Monthly Average Temperature",
X = -20
},
Subtitle = new Subtitle
{
Text = "Source: WorldClimate.com",
X = -20
},
Legend = new Legend
{
Layout = LegendLayout.Vertical,
Align = LegendAlign.Right,
VerticalAlign = LegendVerticalAlign.Middle,
BorderWidth = 0
},
Series = new List<Series>
{
new SunburstSeries
{
Name ="Test",
Data = data,
//LevelSize = new SunburstSeriesLevelSize
//{
// Unit = SunburstSeriesLevelSizeUnit.Percentage,
// Value = 100
//},
Levels = new List<SunburstSeriesLevels>
{
new SunburstSeriesLevels
{
LevelSize = new SunburstSeriesLevelsLevelSize{
Unit = SunburstSeriesLevelsLevelSizeUnit.Percentage,
Value = 90
}
},
new SunburstSeriesLevels
{
LevelSize = new SunburstSeriesLevelsLevelSize{
Unit = SunburstSeriesLevelsLevelSizeUnit.Percentage,
Value = 10
}
}
}
}
}
};
I tried many ways but the levels radius never change, did i miss something?
The only one working is the levelsize of the entire serie but i need to set the size for a specific level.
I tried to search but it looks like nobody already encountered any problem.
Level's object levelSize is able do control the size of individual level. It has two properties: unit (pixels / percentage / weight) and value (determined by the unit):
levels: [{
level: 1,
levelIsConstant: false,
levelSize: {
unit: 'pixels',
value: 30
}
}, {
level: 2,
colorByPoint: true,
dataLabels: {
rotationMode: 'parallel'
}
}, {
level: 3,
levelIsConstant: true,
levelSize: {
unit: 'weight',
value: 2
}
}, {
level: 4,
levelIsConstant: true,
levelSize: {
unit: 'percentage',
value: 30
}
}]
Live demo: http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/sunburst-levelsize/
API reference: https://api.highcharts.com/highcharts/series.sunburst.levelSize

On scroll chart max value of data is not coming properly using highchart?

I am using highstock for scroll bar, for first time max value is coming properly but on scroll its not coming fine.
I set max value to 10 and when I am scrolling only 9 is showing.
Here is code, I am using:
this.xAxis = {
title: {
text: (this.Entities[0] && this.Entities[0].EntityType && this.Entities[0].EntityType in window.dashboardconfig.constants.statusOrder) ? window.dashboardconfig.constants.statusOrderText[this.Entities[0].EntityType] : ''
},
categories: _.map(this.Entities, function (sn) {
return sn.EntityName;
}),
min: 0,
max: (this.Entities.length >= 10) ? 9 : null,
scrollbar: {
enabled: true,
},
var series = [{
name: (slotName in window.dashboardconfig.constants.statusOrder) ? window.dashboardconfig.constants.statusOrderText[slotName] : Resources.EventCode_5035,
data: _.map(this.Entities, function (entity) {
return entity.SlotValues.length >= index + 1 ? entity.SlotValues[index] : null;
}),
index: (slotName in window.dashboardconfig.constants.statusOrder) ? window.dashboardconfig.constants.statusOrder[slotName] : 0,
color: window.dashboardconfig.constants.statusColor[slotName]
}];
this.series = _.sortBy(series, function (item) {
return item.index;
}).reverse();
Here 10 recoreds are coming in graph
But on scroll only 9 is coming
I don't know where I am doing wrong.Can please tell me what I is wrong.

How to Add Custom Data to Highchart.js Tooltip

Can you please take a look at This Demo and let me know how I can add some custom data from an array to tooltip in highchart?
var extras = ["Values More Than 1000", "Values More Than 2000", "Values More Than 3000", "Values More Than 4000", "Values More Than 5000"];
As you can see the array length is equal to the column numbers so the extras[0] with go with tooltip for column 1
some thing like
You can customize the tooltip with the formatter option.
tooltip: {
formatter: function () {
var index = this.series.points.indexOf(this.point);
return extras[index] + ': ' + this.y;
},
style: {
width: 250,
fontSize: '15px'
}
}
Here's a jsFiddle:
http://jsfiddle.net/opgp10mj/3/

Titanium: several videoplayers on one view

I'm trying to create several video players in the titanium tableview (something like video gallery), but as i'm adding the video players in the loop, i get only the last in the loop video added.
Consider yGrid = 2, xGrid = 3, i have 6.mp4 only added.
for (var y = 0; y < yGrid; y++) {
var thisRow = Ti.UI.createTableViewRow({
className : "grid",
layout : "horizontal",
height : cellHeight + (2 * ySpacer),
backgroundColor : '#cfffffff',
selectionStyle: 'NONE',
backgroundImage : '/images/backg2.png'
});
var thisPlayer = [];
for (var x = 0; x < xGrid; x++) {
thisPlayer[x] = Titanium.Media.createVideoPlayer({
objName : "video-view",
objIndex : cellIndex.toString(),
left : ySpacer,
height : cellHeight,
width : cellWidth,
url: '/video/'+cellIndex.toString()+'.mp4',
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Titanium.Media.VIDEO_SCALING_MODE_SIZE,
zIndex : 10,
autoplay : false
});
thisRow.add(thisPlayer[x]);
cellIndex++;
}
tableData.push(thisRow);
}
var tableview = Ti.UI.createTableView({
left : 0,
top : App.geometry.menuHeight + App.geometry.lineHeight+5,
bottom : App.geometry.menuHeight + App.geometry.lineHeight,
width : '100%',
backgroundImage : '/images/backg2.png',
data : tableData
});
view.add(tableview);
Where is the issue?
Finally the issue was because IOS doesn't support several videoplayers in one time.
i've solved it like this
for (var x = 0; x < xGrid; x++) {
thisPlayer[x] = Ti.UI.createWebView({
objName : "video-view",
objIndex : cellIndex.toString(),
left : ySpacer,
height : cellHeight,
width : cellWidth,
});
thisPlayer[x].setHtml('<div><video width="100%" height="94%" controls><source src="./video/'+cellIndex.toString()+'.mp4" type="video/mp4"></video></div>');
thisRow.add(thisPlayer[x]);
cellIndex++;
}

Resources