Results in my react table should be like this:
"/.\u0010\u0016u/LGIRLGAV0735017500099A925",
but the result looks like this:
"/.■■u/LGIRLGAV0735017500099A925".
Black squares are actualy empty (only borders).
How to avoid the backslash character being displayed as an empty square?
Also, everithing in between backslashes missing.
Thank you in advance!
\ character followed with some other characters represents JS escape character. In my case \ was followed with u0012 (ie. \u0012). That was presented as: .■.
I was solve the problem in columns.js (subcomponent of React-Table) with JSON.stringify() method. This is most important for this problem, other
is just formating of my print.
// replace null result with '' function replacer(key, value) { // Filtering out properties if (value === null) { return ''; } return value; } export const COLUMNS = [ { Header: "Text", accessor: "text", Cell: ({ value }) => { return JSON.stringify(value, replacer, '').replace(/"/g, '').split("").join(" ")}, },
Related
In the code below, we have a method which is called whenever the user clicks on the 'Sign Up' button (on our Authentication screen). Currently this method has two different conditions, if it doesn't pass these conditions, the user won't be able to sign up.
We'd also like to add one more condition here. We have an array of strings that shouldn't be accepted as usernames (bad words). But if the bad word is used in combination with other letters or numbers, it should also not be accepted.
Example of a "bad word": Charlie
That means Charlie shouldn't be accepted as a username but there's also potential for millions of other combinations, examples: Charlieee, Charlie124342, Charlie6648, 213charlie, ch1chaRliE32, etc. etc.
So would there be any simple method to check whether the username entered contains any of the bad words listed in an array, regardless of whether its used in combination with other characters or not?
Future<String?> usernameValidator({required String? username}) async {
// Validates username complexity
bool isUsernameComplex(String? text) {
final String _text = (text ?? "");
String? p = r"^(?=(.*[ #$!%*?&=_+/#^.~`]))";
RegExp regExp = RegExp(p);
return regExp.hasMatch(_text);
}
final String _text = (username ?? "");
// Complexity check
if (isUsernameComplex(_text)) {
return "Username can only contain letters and numbers.";
}
// Length check
else if (_text.length < 3 || _text.length > 16) {
return "Username must be between 3-16 characters long.";
}
return null;
}
see if this helps:
List<String> badwords = [
'charlie',
'another_badword',
];
List<String> input = [
'Charlieee',
'Charlie124342',
'Charlie6648',
'213charlie',
'ch1chaRliE32',
'spaghetti',
];
input.forEach((text) {
final bwIndex = badwords.indexWhere(
(badword) => text.toLowerCase().contains(badword),
);
if (bwIndex != -1) {
print('$text is bad word, similar to ${badwords[bwIndex]}');
} else {
print('$text is not a bad word');
}
});
How to remove trigger character on autocomplete in tinyMCE? Let's assume that the trigger character is #.
Once I select an autocomplete item, I wish to remove the preceding # character.
Here is an example of using the autocompleter and not including the trigger character:
https://fiddle.tiny.cloud/u7haab/12
The fetch function determines what is returned:
fetch: function (pattern) {
return new tinymce.util.Promise(function (resolve) {
var results = getMatchedNames(pattern).map(function (char) {
return {
type: 'autocompleteitem',
value: char.value, //This VALUE is what is inserted into the content via the onAction method
text: char.value,
}
});
resolve(results);
});
}
...and the onAction method takes the value and inserts it into the editor:
var onAction = function (autocompleteApi, rng, value) {
editor.selection.setRng(rng);
editor.insertContent(value);
autocompleteApi.hide();
};
Unless you explicitly choose to include the trigger character it won't be included if you follow this pattern.
This is function which is I'm using at liveChange event:
if (oEvent.mParameters.value.indexOf(" ") === 0) {
sap.m.MessageToast.show("Space character is not allowed");
oEvent.preventDefault();
return false;
}
By using this code I have to restrict the whitespaces at the beginning in the input field. I tried a lot, I'm getting the message but it is taking the whitespace. How can I make an input field display only message and it should not take whitespaces.
To "invasively" remove the whitespace in the beginning of the input, you can do something like this:
onLiveChange = function(oEvent) {
var sValue = oEvent.getParameter('value');
if (sValue[0] === ' ') { // or use sValue.match(/^ /)
oEvent.getSource().setValue(sValue.trimStart());
sap.m.MessageToast.show("Space character is not allowed");
}
}
Also have a look at this SAPUI5 Demokit Sample as well as the validationError and validationSuccess events of class `sap.ui.core.Core' to get an idea of the recommended way of handling validation.
I am struggling with kendo-ui grid foreign key column and mvvm
I would like to be able to combine the "Foreign Key Column" example with the "MVVM" example
My question is: "how do I data-bind the values property of a look-up field?"
So this is kind of an older post, but I just had to work around the same issue and found this while trying to solve. Figured I'd answer the question for posterity.
The "values" property doesn't seem to work 100% in the kendo grid in MVVM. I have worked around this in a two step process.
Tack "this.viewModel" (where "viewModel" is whatever you are calling your VM) in front of the "loggerSeverityValues". This will give you a dropdownlist when editing the field.
Utilize the template functionality to display the correct value in the grid. I use a little function to make this easier:
getText: function (matchValue, valuesArray, text, value)
{
if (text === undefined)
{
text = 'text';
}
if (value === undefined)
{
value = 'value';
}
var retText = "No Value Found";
finalArr = $.grep(valuesArray, function (val, integer)
{
return val[value] == matchValue;
});
if (finalArr.length > 0)
{
retText = finalArr[0].text;
}
return retText;
}
The final look of the field will be something along the lines of this:
{ field: 'severity', width: 270, values: this.viewModel.loggerSeverityValues, template: '#: getText(severity, this.viewModel.loggerSeverityValues) #' }
Note that with the getText() function you can override the text and value parameters if you need to.
Anyway this worked for me. Kind of a workaround, but as of release 2014.3.1411 anyway it doesn't appear that the kendo MVVM bindings will work properly with foreign keys.
EDIT:
For anyone now using the kendo ng2+ components, same pattern but with a pipe transform works.
Pipe:
import { Pipe, PipeTransform } from '#angular/core';
#Pipe({ name: 'getText' })
export class GetTextPipe implements PipeTransform {
transform(value: any, idPropertyName: string, valuePropertyName: string, valueArray: any[]): any {
if (value != null && valueArray != undefined) {
let retIndex = valueArray.map(v => v[idPropertyName]).indexOf(value);
return valueArray[retIndex][valuePropertyName];
}
else {
return '';
}
}
}
Usage:
<kendo-grid-column field="severity" title="Severity" width="150px">
<template kendoGridCellTemplate let-dataItem="dataItem">
{{dataItem.severity | getText:'severity':'severityName':loggerSeverityValues}}
</template>
</kendo-grid-column>
Is there any way to avoid users to input line-breaks in UIInputs?
Do not want the user to be able to write line-breaks in username inputs, for example.
I searched for multiline attribute but it seems it only exists in UILabel objects.
Tried "validation:Username" but this option does not allow to write characters like "-", which is a valid username character of my application.
Thanks!
You can similarly limit your input field to a single line by setting the Max Lines property to 1 on the UILabel.
http://www.tasharen.com/forum/index.php?topic=6752.0
Had to check the UIInput.cs file to know how to ignore newlines, and I found this:
case KeyCode.KeypadEnter:
{
ev.Use();
bool newLine = (onReturnKey == OnReturnKey.NewLine) ||
(onReturnKey == OnReturnKey.Default &&
label.multiLine && !ctrl &&
label.overflowMethod != UILabel.Overflow.ClampContent &&
validation == Validation.None);
if (newLine)
{
//Insert("\n");
}
else
{
UICamera.currentScheme = UICamera.ControlScheme.Controller;
UICamera.currentKey = ev.keyCode;
Submit();
UICamera.currentKey = KeyCode.None;
}
return true;
}
So in order to avoid newlines, you need to do:
UILabelObject.multiLine = false;
UIInputObject.onReturnKey = UIInput.OnReturnKey.Default;
Doing that, bool newLine becomes false and performs Submit();