I am using the noUISlider in my rails project.
noUiSlider.create( slider, {
start: [3],
connect: 'lower',
step: 1,
range: {
'min': 1,
'max': 9
},
pips: {
mode: 'steps',
density: 20
},
tooltips: true,
format: {
from: function(value) {
return (parseInt(value)+" days");
},
to: function(value) {
return (parseInt(value)+" days");
}
}
});
I want it to be a measure of days in the tooltip. So I added the format part as above. But start: 3 wont work anymore. It starts from 1 instead. If I remove the format, start works fine.
I tried removing the format and editing the noUi-tooltip text property from js (appending "days"), but that doesnt work either.
Any help ?
In format, the from function converts the value from the formatted string to a numerical value. You'll want to cast your input to a number there:
format: {
from: Number,
to: function(value) {
return (parseInt(value)+" days");
}
}
Related
One can reproduce the problem.
Create new Spreadsheet.
Take SpreadsheetId (https://docs.google.com/spreadsheets/d/1rp11nqj0t0x1111111111111111111111111137Wj4XU/edit#gid=0, here it is 1rp11nqj0t0x1111111111111111111111111137Wj4XU)
Fill range A1:F15 with any content, let's use 'lorem ipsum' string, for instance.
Visit https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate
4.1 Look at right side where one can find "Try this method"
4.2 Fill field "spreadsheetId" with one you've taken on step 2.
4.3 Fill "Request body" with
{
"requests": [
{
"repeatCell": {
"cell": {
"userEnteredFormat": {
"textFormat": {
"strikethrough": true
}
}
},
"fields": "*",
"range": {
"startRowIndex": 2,
"endRowIndex": 2,
"startColumnIndex": 1,
"endColumnIndex": 3
}
}
}
]
}
4.4 Press "Execute" button at the bottom of right side.
5. Check you spreadshet.
6. No error, nothing happened.
What am I doing wrong ?
Modification points:
In your following request body, the values of startRowIndex and endRowIndex are the same. By this, this request body cannot be correctly worked. I thought that this might be the reason for your current issue of No error, nothing happened..
{
"requests":[
{
"repeatCell":{
"cell":{
"userEnteredFormat":{
"textFormat":{
"strikethrough":true
}
}
},
"fields":"*",
"range":{
"startRowIndex":2,
"endRowIndex":2,
"startColumnIndex":1,
"endColumnIndex":3
}
}
}
]
}
And also, in your request body, even when the above modification is reflected, the cell values are cleared by "fields":"*". Please be careful about this.
When these points are reflected in your request body, how about the following modification?
Modified request body:
{
"requests": [
{
"repeatCell": {
"cell": {
"userEnteredFormat": {
"textFormat": {
"strikethrough": true
}
}
},
"fields": "userEnteredFormat.textFormat.strikethrough",
"range": {
"startRowIndex": 0,
"endRowIndex": 15,
"startColumnIndex": 0,
"endColumnIndex": 6,
}
}
}
]
}
In this modified request body, from Fill range A1:F15 with any content, let's use 'lorem ipsum' string, for instance., the cells "A1:F15" are used. So, strikethrough is used for these cells.
In your request body, sheetId is not used. So, in this case, the 1st tab in Google Spreadsheet is used. Please be careful about this. If you want to use it for the specific sheet, please add the property of "sheetId": ### to range. ### is the sheet ID.
References:
RepeatCellRequest
GridRange
I am trying to use the conditional filter to check a range between two numbers using google sheets api I keep getting this syntax error how do I fix it please here is my code:
const addFilterViewRequest = [
{
'addFilterView' : {
filter : {
title : 'PO_Log Precentage',
range : {
sheetId : 1701531392,
'startRowIndex': 1,
'startColumnIndex':1
},
'criteria': {
19:{
'condition': {
'type': 'NUMBER_BETWEEN',
'values':[
{
"userEnteredValue" : "80"
}
],
}
}
}
}
}
}
]
Sheets.Spreadsheets.batchUpdate({ requests: addFilterViewRequest },spreadsheet_id);
}
ConditionType
NUMBER_BETWEEN
The cell's value must be between the two condition values. Supported by data validation, conditional formatting and filters. Requires exactly two ConditionValues .
'values':[
{
"userEnteredValue" : "0"
},
{
"userEnteredValue" : "80"
}
],
I'm facing an issue when defining an own custom format using handlebars.js and handlebars-intl.js.
According to Handlebars you define the formats like
var intlData = {
"locales": "de-CH",
"formats": {
"number": {
"CHF": {
"style": "currency",
"currency": "CHF"
}
}
}
};
and then your handlebar expression
{{formatNumber Amount "CHF"}}
The console tells me that there is a reference error: "Could not find Intl object: formats.number.CHF".
And the formatNumber function throws an error saying "A number must be provided to {{formatNumber}}.
This is how the function looks like when throwing this exception
function formatNumber(num, format, options) {
assertIsNumber(num, 'A number must be provided to {{formatNumber}}');
if (!options) {
options = format;
format = null;
}
var locales = options.data.intl && options.data.intl.locales;
var formatOptions = getFormatOptions('number', format, options);
return $$helpers$$getNumberFormat(locales, formatOptions).format(num);
}
num is filled with my sample data (100000), format with "CHF" and options contains all data provided by the model.
When I directly write the format and style into the expression it works properly and I can't really see what I'm either missing or doing wrong since I'm sure that I'm following the guidelines.
This is how you would define the format directly in the expression
{{formatNumber price style="currency" currency="USD"}}
Any help is appreciated. Thanks in advance.
Update
This is my js
$(document).ready(function () {
HandlebarsIntl.registerWith(Handlebars);
renderTemplate(#Html.Raw(Json.Encode(Model)))
});
var templateSource = $('#deals-template').html();
var handlebarsTemplate = Handlebars.compile(templateSource);
var intlData = {
"locales": "de-CH",
"formats": {
"number": {
"CHF": {
"style": "currency",
"currency": "CHF"
},
"percentage": {
"style": "percent"
}
}
}
};
function renderTemplate(data) {
$('#template').append(handlebarsTemplate(item, { data: { intlData }}));
});
}
I believe I'm passing the intlData variable correctly so this can't be the issue.
Example by handlebars example
var html = template(context, {
data: {intl: intlData}
});
I've finally figured out what caused this exception.
As I've mentioned the handlebars example looks like this
var html = template(context, { data: {intl: intlData} });
And this is what I've passed
$('#template').append(handlebarsTemplate(item, { data: { intlData }}));
I've not defined intl..
So this is the correct way
$('#template').append(handlebarsTemplate(item, { data: { intl: intlData }}));
Maybe this answer will save someone a few hours of searching but honestly it's pretty obvious.
I am having several experiments a day storing the error of the experiment and a boolean value (if the result is ok) in elasticsearch.
Now, I would like to display the results in a graph (using highchart js).
I use an aggregation query like this to receive the aggregated errors for each day including the standard deviation:
query: {
filtered: {
filter: {
range : {
date: {
"gte":"2015-1-1",
"lte": "2016-1-1,
"time_zone": "+1:00"
}
}
}
}
},
// Aggregate on the results
aggs: {
group_by_date: {
terms:{
field:"date",
order: {_term:"asc"}
},
aggs:{
error_stats:{
extended_stats:{
field:"error"
}
}
}
}
}
The problem I face is that I cannot retrieve the boolean values the same way as I get the double errors from the DB.
When I just change the field name to "ok" in
aggs:{
error_stats:{
extended_stats:{
field:"ok"
}
}
}
I receive this error message:
ClassCastException[org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData cannot be cast to org.elasticsearch.index.fielddata.IndexNumericFieldData
However, it would be OK to aggreate all the boolean values usign true as 1 and false as zero and then to receive a mean value for each day.
Can anyone help me with this?
Thanks alot!
First 0/1 representation is not exactly ES Boolean representation. There is a Boolean type for as true/false.
Second stats aggregation can be only done on numeric field and not on string field.
That is why it worked for 0/1 representation.
You can transform this value using scripts in extended stats
{
"aggs" : {
...
"aggs" : {
"grades_stats" : {
"extended_stats" : {
"field" : "grade",
"script" : "_value == 'T' ? 1 : 0",
}
}
}
}
}
To see some example usage of scripting in aggregation , you can look here.
i was trying to do a Cell Editing based on this documentation
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:cell_editing
I have two questions:
How can i get the Index of my row posted to the server:
The information i'm getting posted is the following:
a) value of the cell
b) RowId
The thing is that the rowId doesn't help me. I need the actual Id of the information I'm displaying so i can do the server update with that Id.
colNames: ['Id', 'Codigo', 'Nombre'],
colModel: [
{ name: 'Id', index: 'Id', width: 50, align: 'left', hidden: true },
{ name: 'Codigo', index: 'Codigo', width: 55, align: 'left', editable: true, editrules:
{ number: true} },
{ name: 'Nombre', index: 'Nombre', width: 200, align: 'left' }],
I need the value of the column 'Id' to do my update.
2.I don't understand in the documentation how to manage an error from the server, so I can display the error message.
Thank you very much!
Notes:
a) I've already asked in the forum of trirand, but no one reply it to me.
b) If anyone has done this, it would help if help me pasting the code.
c) I'm working on MVC 2 Asp.net
mostly one you inline editing or form editing and not cell editing. I recommend you to switch to one of the two modern form editing or you
The information RowId is already the value of the column 'Id'. getInd(rowid,false) method returns the index of the row in the grid table specified by id=rowid.
To be able to display error returns from server you needs know the format of data returned from server in the error case. If error returned from server have, for example, JSON format {"Detail":"error text"} (errors from WFC service) you can define loadError parameter of jqGrid like:
loadError: function(xhr, st, err) { alert(errorTextFormat(xhr)); }
where errorTextFormat function which decode the error message and can looks like
var errorTextFormat = function (data) {
var str = data.responseText.substr(0, 10);
if (str === '{"Detail":') {
var errorDetail = jQuery.parseJSON(data.responseText);
var s = "Error: '";
s += data.statusText;
s += "'. Details: ";
s += errorDetail.Detail;
return s;
} else {
var res = "Status: '";
res += data.statusText;
res += "'. Error code: ";
res += data.status;
return res;
}
};
The same function you can use to decode errors of row editing (at least inline editing or form editing). ASP.NET MVC returns mostly messages in HTML format so your error decoding function should be another. I don't use cell editing as the most other people do, so can not help you in the case or customizing of the error messages in cell editing.
Q1:
you can use Key:true , editable: true, in colModel
{ key:true, name: 'Id', index: 'Id', width: 50, align: 'left', editable: true, hidden:true}
Then in add/edit method ( add beforeShowForm method in add/edit method), you have to explicitly hide this field the field of id inside of beforeShowForm method
$('#tr_Id').hide();
i.e
beforeShowForm: function (e) {
$('#tr_Id').hide();
}
Q2:
add 'afterSubmit' method in add/edit/delete method , i'm using Web api Server ,
i.e
afterSubmit: function (response) {
if (response.statusText == 'Created') {
// alert("Create Successfully")
ShowMessage("Add Successfully", 'Success');
//reload the grid
$(this).jqGrid("setGridParam", { datatype: 'json' });
return [true];
}
else {
ShowMessage("Operation Failed", 'Error');
return [false];
}
},
I hope this will work for you. Still u Need Any kind of help please comment below