could you help me for solve this issue ?
i have 2 or more field base on oData with different form. if i press with oData value (subty "1"), the result is true and oData (subty "2") is false.
then i press value "2", the result is true but value 1 is false
let' see my code :
in view, i write this code :
form 1
**
<f:SimpleForm visible="{path: 'Subty', formatter:'model.formatter.statusText'}"
/>
**
form 2
**
<f:SimpleForm visible="{path: 'Subty', formatter:'model.formatter.statusText1'}"
/>
*
in formatter, i write this code :
statusText: function (sStatus) {
if (sStatus==="1"){
return "true";}
if (sStatus==="2")
{return "false";}
else{
return "";
}
},
statusText1: function (sStatus) {
if (sStatus==="1"){
return "false";}
if (sStatus==="2")
{return "true";}
else{
return "";
}
}
i have error with that code.
Since the visible property is of type 'boolean' you will have to return a boolean value (true|false) in your formatter!
Please note:
"true" !== true
typeof "true" !== "boolean"
"false" !== false
typeof "false" !== "boolean"
typeof "" !== "boolean"
BR
Chris
Related
I have module where I need filter the data, base on date value and via seaching the words. Right now I experience problem. by the way I using laravel for the backend and React js for front end. but I will give you the scenario happen right now.
1. When I start fire searching the data this is working properly.
2. When I Click the date filter the data is filtering base on the date value.
3. This is the problem, When I try to change the searching text value in the textbox the data is not filtering anymore, how to solve that problem. my first thinking to solve it is to make the date filter null but I really don't know how to do it. but to make more understandable I will show you guys my code.
Code Sample:
let { loadReceiveChecks, receiveCheckResponse, keyWords, searchWord } = this.props
let keyStatus = keyWords.toLowerCase();
if(keyStatus) {
// this is for date range
return Object.keys(receive_date).some(
(key) =>
typeof receive_date[key] === "string" &&
receive_date[key].toLowerCase().includes(keyStatus)
);
}else if(searchWord) {
// this is for search text input box
return Object.keys(item).some(
(key) =>
typeof item[key] === "string" &&
item[key].toLowerCase().includes(searchWord)
);
}else {
// return all the list data.
return Object.keys(item).some(
(key) =>
typeof item[key] === "string" &&
item[key].toLowerCase().includes(searchWord)
);
}
From the limited information I have, I conclude that your best option is to set the state to null when the date range was triggered. It could look like this:
let {
loadReceiveChecks,
receiveCheckResponse,
keyWords,
searchWord,
updateParentState, // function which contains this.setState()
} = this.props;
let keyStatus = keyWords.toLowerCase();
if (keyStatus) {
updateParentState(null); // set parent state to null
// this is for date range
return Object.keys(receive_date).some(
key =>
typeof receive_date[key] === "string" &&
receive_date[key].toLowerCase().includes(keyStatus)
);
} else if (searchWord) {
// this is for search text input box
return Object.keys(item).some(
key =>
typeof item[key] === "string" &&
item[key].toLowerCase().includes(searchWord)
);
} else {
// return all the list data.
return Object.keys(item).some(
key =>
typeof item[key] === "string" &&
item[key].toLowerCase().includes(searchWord)
);
}
I've 5 cells in a table. If the value are empty for those cells i need to disable them.
I can do something like this for each cells which work's.
function cellOne(params) {
if (params.value === null || params.value === undefined) {
return false
} else {
return true;
}
}
"CellOne": { disabled:cellOne }
is there any other way to check null value of each cell and add disable property instead of creating multiple function for each cells. Please help
You don't need to go for typescript code.You can do it in the template itself.
<your-cell [disabled]="!params.value"></your-cell>
Your function would return the same thing as :
function cellOne(params) {
return params.value != null
}
which you can easily inline instead of having a separate function for that.
To check for params that might be null or undefined too, you can use :
return params && params.value != null
using
var states = {
Abbreviation: "AR",
Name: "Arkansas"
}
Why will this work.
$.each(states, function () {
var o = {
value: this.Abbreviation,
text: this.Name
}
if (this.Abbreviation === "AR") { //hardcoded for you pleasure
o.selected = 'selected';
}
e.append(
$('<option/>', o)
);
});
But not this:
$.each(states, function () {
e.append(
$('<option/>', {
value: this.Abbreviation,
text: this.Name,
selected: (this.Abbreviation === csc.statesDDL.txt().val() ? 'selected' : '')
})
);
});
Are there restrictions to .append within jquery for ternary :? operators?
Notes: I have a logged the output of the if statements, when running the commented out code it shows ALL options as selected, the the logs output only 1 options = true. The uncommitted out code, behaves as expected.
It's not the ternary that's the issue, it appears to be how jQuery/HTML is handling the empty string. jQuery is most likely not resolving the property to an explicit false and thus creating an element with a "selected=''" which the browser may just be interpreting as "selected" which I believe is from an old HTML standard that recognized that as being selected. If you make the false explicit it will work:
selected: (this.Abbreviation === csc.statesDDL.txt().val() ? 'selected' : false)
I'm guessing it is not evaluating it as
((this.Abbreviation === csc.statesDDL.txt().val()) ? 'selected' : '')
but is evaluating it as
(this.Abbreviation === (csc.statesDDL.txt().val() ? 'selected' : ''))
If I want to check if an element is the first child of it's parent, I can do it like this:
if (element.previousSibling == null) {
...
}
But is it "wrong" to do it like this:
if (!element.previousSibling) {
...
}
? Since it still works since !!null == false and !!anyElement == true?
Seem to be having a little trouble getting some validation to work.
Currently trying to implement a system that will redirect a user if a variable is false, AND a form contains 0000 or 1111.
Example:
if xml_response == "false" && form == ("0000" || "1111") {
window.location.replace("");
} else {
submit.form
}
I've been able to get it working for 0000. If XML generates false, and form contains 0000, successful redirection.
If XML generates false and form contains 1111, no dice. I'm thinking it has to do with how I'm formatting my operators. Any ideas?
Here's my statement:
if (response == "false" && document.forms['Form'].id.value==("0000" || "1111") ) {
window.location.replace("http://url/");
} else {
document.getElementById("submit_form").submit();
}
That's invalid, you have to check for each value individually
if ((xml_response == "false") && (form == "0000" || form == "1111")) {
window.location.replace("");
} else {
submit.form
}
Note that you're checking for the string false and strings that look like numbers.
There's also the option to check an array for multiple values
if (
( response == "false" ) &&
( ['0000','1111'].indexOf(document.forms['Form'].id.value) != -1 )
)
{
window.location.replace("http://url/");
} else {
document.getElementById("submit_form").submit();
}
or even
/(0000|1111)/.exec(document.forms['Form'].id.value)
Note that:
document.forms['Form'].id.value
will attempt to find a form in the document with a name or ID of "Form". If it finds one, it will access it's ID property, which is a string, and attempt to read it's value property. Strings don't have a "value" property, so the result will be the value undefined.