How to add to a store of a combobox in extjs 4? - extjs4

I have tried the following from various examples and none of them work:
folderCombo.store.add({text: 'All', value: 'ALL'});
folderCombo.getStore.add({text: 'All', value: 'ALL'});
folderCombo.getStore().add(new grid.store.recordType({text: 'All', value: 'ALL'}));
folderCombo.store().add(new grid.store.recordType({text: 'All', value: 'ALL'}));
folderCombo.getStore().add(folderCombo.getStore().recordType({text: 'All', value: 'ALL'}));
Where folderCombo is my combobox. If I console.log folderCombo.store it shows the current store but never the store with the extra data item I try to add above.
Please advise.

Try:
folderCombo.getStore().add({text: 'All', value: 'ALL'});
or:
folderCombo.getStore().loadData({text: 'All', value: 'ALL'},true);

Related

Read value from search request Datatable?

I am trying to read value from search box of Datatable.
This is request payload:
[Object: null prototype] {
draw: '8',
'columns[0][data]': '_id',
'columns[0][name]': '',
'columns[0][searchable]': 'true',
'columns[0][orderable]': 'true',
...
start: '0',
length: '50',
'search[value]': 'id3dsd3dsdddsddsd',
'search[regex]': 'false'
}
I want to get value from search[value]. I get this error after using this code:
req.body.search.value
TypeError: Cannot read properties of undefined (reading 'value')
Anyone can help me!
Hope this would solve your problem.
let search_str = req.body['search[value]'];

Object method approach to .setLeftParens .setRightParens & .setOr in SuiteScript 2.X

I'm searching for the equivalent in SS 2.X of this:
new nlobjSearchFilter('postingperiod', 'transaction', 'is', period).setLeftParens(1).setOr(true)
This seems to not work:
searchMod.createFilter({
name: 'postingperiod',
operator: searchMod.Operator.IS,
join: 'transaction',
values: period
}).setLeftParens(1).setOr(true);
You can use filter expressions (Search.filterExpression) to group filters using and or or.
The sample below is from the Help Center:
search.create({
type: search.Type.CUSTOMER,
filters: [
['email', search.Operator.STARTSWITH, 'kwolff'],
'and',
[
['id', search.Operator.EQUALTO, 107], 'or',
['id', search.Operator.EQUALTO, 2508]
]
]
});

Populate data with custom function

How can I add custom filter options AND all the other data to a custom function?
Below is my code. I would like to have Yes and No filters, but also filters for all the other values in the column.
{column_number: creator_index,
filter_type: 'custom_func',
custom_func: Creator_Filter_Function,
data: [
{value: 'yes', label: 'Yes'},
{value: 'no', label: 'No'},
],
filter_default_label: "All"
},
You should use the append_data_to_table_data option for your filter
From docs:
append_data_to_table_data
Required: false
Type: string
Default value: undefined
Possible values: before / sorted
Description: Use 'before' to place your data array before the values that yadcf grabs from the table
use 'sorted' to place the data array sorted along with the values that yadcf grabs from the table
Note: 'sorted' option will have affect only if you data is an array of primitives (not objects)
So eventually your code will look like this
{
append_data_to_table_data: 'before',
column_number: creator_index,
filter_type: 'custom_func',
custom_func: Creator_Filter_Function,
data: [
{value: 'yes', label: 'Yes'},
{value: 'no', label: 'No'},
],
filter_default_label: "All"
},

How do you set <select> value/option in edit/new template - ExpressJS

I'm trying to use a partial to share a _form.html across an new.html and edit.html templates in ExpressJS. The problem is with the select tag.
How do you get a select HTML element to have the correct option selected in an edit form? If you use
<select value="#{blob.kind || ''}">
The select doesn't show the option whose value is equal to the blob.kind.
In order to specify a selected option, a selected attribute needs to be added to the option element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
Assuming the blob.kind property is a value string, you could write the Jade for your select and option elements as follows:
-
var options = [
{value: 'option1', text: 'Option 1'},
{value: 'option2', text: 'Option 2'},
{value: 'option3', text: 'Option 3'},
{value: 'option4', text: 'Option 4'}
];
select
each obj in options
if (blob.kind === obj.value)
option(value= obj.value, selected)= obj.text
else
option(value= obj.value)= obj.text
For future reference, Jade has been renamed to Pug.
I used to do this as follows:
select
each obj in options
option(value= obj.value, selected=blob.kind === obj.value ? true : false)=
obj.text
Sean's suggestion is excellent, but his syntax didn't quite work for me. Here's what I ended up with:
- const stateOptions = [{value:'AL', text:'Alabama'}, ...]
select#state(name='state' required)
each option in stateOptions
if (option.value === meeting.state)
option(value=(option.value) selected) #{option.text}
else
option(value=(option.value)) #{option.text}

Best way to parse a query like string

So I am building a query like search component for a web application I am working on, similar to the search bar seen for Jira's advance issues search:
https://jira.atlassian.com/browse/WBS-167?jql=status%20%3D%20Accepted
The search is basically very similar to the WHERE statement in SQL but only supporting selected set of comparison operators (for instance I don't plan on supporting the between comparison operator). First thing that came to mind is to use regex but I hear that SQL is the 3rd worst thing to parse with regex.
As an example, this would probably be a complex query I would want to be able to parse:
firstName = 'john' OR (lastName = 'doe' AND (status IN (1,3,5) OR type NOT IN (2, 4, 6)) AND username CONTAINS 'd' AND (type = 1 OR status = 2)
and would would want the result of parsing this string to looks something like this:
[{
field: 'firstName',
comparison: '=',
value: 'john'
}, {
connector: 'OR',
items: [{
field: 'lastName',
comparison: '=',
value: 'doe'
}, {
connector: 'AND',
items: [{
field: 'status',
comparison: 'IN',
value: [1,3,5]
}, {
connector: 'OR',
field: 'type',
comparison: 'NOT IN',
value: [2,4,6]
}]
}]
}, {
connector: 'AND',
field: 'username',
comparison: 'CONTAINS',
value: 'd'
}, {
connector: 'AND',
items: [{
field: 'type',
comparison: '=',
value: 1
}, {
connector: 'OR',
field: 'status',
comparison: '=',
value: 2
}]
}]
If regex is a bad choice (and trying to work with regex for a couple of hours did not produce any good results), what is the best why to try to parse this type of string?
It looks like you are developing a small and simple language. As ebyrod said you should use a grammar-based parser instead of regex. Lex and Yacc are great and easy tools for the job. Depending on the language you are using, there are different alternatives.
Take a look at this.
As you can see, you will need to define all the supported operations that can appear on your input. This is done on the Lex file. Then you will need to define your syntax structure (grammar) and the last step is composing your output string.