Free-jqGrid: Dynamically Setting Search input According to Custom Selected Operand - jqgrid

I'm using free jqgrid, I implemented custom search operands using "customSortOperations: {}", I want to change the search field input to a select when I choose one of my custom operands, is there a way to do that? if not is there an event that fires when the operand is chosen to listen for it and implement my custom search field change? here is a sample of how I'm using "customSortOperations: {}"
$.extend($.jgrid.defaults, {
customSortOperations: {
tst: {
operand: "T",
text: "Test",
}
},
});

You posted only short fragment of your code. Thus, I'm not sure that I full understand your problem. To use new custom search operand you should define filter method inside of customSortOperations.tst and include the operation "tst" inside of searchoptions.sopt of column definition in colModel. If you want to use the new operation "tst" as default searching operation then the operation "tst" should be the first in searchoptions.sopt array. See for example https://jsfiddle.net/OlegKi/f3gLde6m/2/ created for the old answer for more details.

Related

Powerautomate Parsing JSON Array

I've seen the JSON array questions here and I'm still a little lost, so could use some extra help.
Here's the setup:
My Flow calls a sproc on my DB and that sproc returns this JSON:
{
"ResultSets": {
"Table1": [
{
"OrderID": 9518338,
"BasketID": 9518338,
"RefID": 65178176,
"SiteConfigID": 237
}
]
},
"OutputParameters": {}
}
Then I use a PARSE JSON action to get what looks like the same result, but now I'm told it's parsed and I can call variables.
Issue is when I try to call just, say, SiteConfigID, I get "The output you selected is inside a collection and needs to be looped over to be accessed. This action cannot be inside a foreach."
After some research, I know what's going on here. Table1 is an Array, and I need to tell PowerAutomate to just grab the first record of that array so it knows it's working with just a record instead of a full array. Fair enough. So I spin up a "Return Values to Virtual Power Agents" action just to see my output. I know I'm supposed to use a 'first' expression or a 'get [0] from array expression here, but I can't seem to make them work. Below are what I've tried and the errors I get:
Tried:
first(body('Parse-Sproc')?['Table1/SiteConfigID'])
Got: InvalidTemplate. Unable to process template language expressions in action 'Return_value(s)_to_Power_Virtual_Agents' inputs at line '0' and column '0': 'The template language function 'first' expects its parameter be an array or a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#first for usage details.'.
Also Tried:
body('Parse-Sproc')?['Table1/SiteconfigID']
which just returns a null valued variable
Finally I tried
outputs('Parse-Sproc')?['Table1']?['value'][0]?['SiteConfigID']
Which STILL gives me a null-valued variable. It's the worst.
In that last expression, I also switched the variable type in the return to pva action to a string instead of a number, no dice.
Also, changed 'outputs' in that expression for 'body' .. also no dice
Here is a screenie of the setup:
To be clear: the end result i'm looking for is for the system to just return "SiteConfigID" as a string or an int so that I can pipe that into a virtual agent.
I believe this is what you need as an expression ...
body('Parse-Sproc')?['ResultSets']['Table1'][0]?['SiteConfigID']
You can see I'm just traversing down to the object and through the array to get the value.
Naturally, I don't have your exact flow but if I use your JSON and load it up into Parse JSON step to get the schema, I am able to get the result. I do get a different schema to you though so will be interesting to see if it directly translates.

Mapboxgl-js expression add & max of two columns

I am trying to get max & sum of two columns in a filter expression using MapboxGL-js. The two columns of interest may contain nulls.
Tried this for addition and it does not work (nothing shows up on the map)
["+",["to-number",['get', "col1"]],["to-number",['get', "col2"]]]
For max,I tried this and does not work either.
["max",["to-number",['get', "col1"]],["to-number",['get', "col2"]]]
Any suggestions? Thanks!
The filter defined in mapboxgl-js is
filter is a property at the layer level that determines which features should be rendered in a style layer.
In official mapboxgl-js example you can see that in case condition is true the feature will be rendered:
"filter": ["==", "icon", symbol]
where "icon" is equal to symbol (a variable that is set to the selected feature's icon property).
In your example there are no conditional operation done.
In case you are trying to show the "sum" or "max" as a layer's "text-field", you should use it there and not in filter, and return string after completing your Math operations.
so it will be
"test-field": ["to-string", ["max",["to-number", ["get", "col1"]],["to-number", ["get", "col2"] ]]],
Link to Filter Doc
Link to Expressions Docs
Hope this helps

MS Flow: How to achieve something like `_.find()` (lodash/JS)

How can I use MS Flow to select an individual object, by value for a specified property, from an array?
Example array:
[
{
item_id: '1234'
},
{
item_id: '4567'
}
]
In the example above, I may only want to work with the first object and the rest of its available properties.
Happy to use the Workflow Definition Language and/or any of the Data Operations actions.
I solved this by using the "Data operations - Filter" action.
Ignore the error in red - it is an array.
My left-hand expression for "item_id" is:
item()?['item_id']
And then I statically enter the item ID I wish to access in the right-hand input.
DocumentNo Item will then be an array itself with only 0 or 1 elements and can be used like so:
body('DocumentNo_Item')?[0]?['label']

zingchart setseriesdata visibility issue

Pretty straight forward question, as soon as i use setseries data the visibility my pie chart is no longer visible. I have checked the plot object and the series were updated correctly, however since I do not find a visibility attribute anywhere in the plot object, i am at a loss.
The lack of zingcharts documentation and proper examples does not aid either. Im fairly certain this is a simple scenario to solve, but I've been unable to do so.
zingchart.exec('organismplot', 'setseriesdata', {
"data": [
{
"values":data_update.organisms,
"text":"active",
"background-color":"#2d4962",
"border-width":"1px",
"shadow":0,
"visible":1
},
{
"values":(data_update.totalorganism-data_update.organisms),
"text":"passive",
"background-color":"#2d4962",
"border-width":"1px",
"shadow":0,
"visible":0
}]
I'm a member of the ZingChart team, and I'm happy to help you out!
What is the type of data_update.organisms and data_update.totalorganism-data_update.organisms? Make sure that you are passing a single element array, or if those are simply single values, wrap the variables in brackets to create a single value array for the "values" attribute. E.G.:
"data": [
{
"values":[data_update.organisms], // If data_update.organisms is a single value.
"text":"active",
"background-color":"#2d4962",
"border-width":"1px",
"shadow":0,
"visible":1
},
{
"values":[data_update.totalorganism-data_update.organisms], // Again, single value array.
"text":"passive",
"background-color":"#2d4962",
"border-width":"1px",
"shadow":0,
"visible":0
}
]
I've created a demo using your exact method call, except I've changed the "values" attributes to use a single value array, which are needed for pie charts. Check out the demo here.
I hope that helps. Let me know if you need some more help!

JQGrid with similar grids is there a way to reuse your javascript code rather then setting up every option again?

When I am using multiple grids on the same page, or over my entire website, is there any way to abstract out the setup of common grid components? Ex the colModel section, or other components that would be the same between two grids, while giving me the option to make each grid unique, Ex in name, caption, etc.
Basically what this comes down to is I want to avoid the wall of text that comes with the setup of multiple grids that are highly similar.
I was able to achieve some of what I was looking for.
I was able to take the largest chunk of repeated code, the colModel:[..] and turn that into a variable and then call on it.
Ex
var colModelForReuse = [{name: 'exName', index: 'exIndex' ..... },
{.......................................}];
and then later in my Grid setup
colNames: [ 'exName', .....],
colModel: colModelForReuse,
pager: pagerName,
...
Yes, you could create a function that creates your actual grid, and then pass options to it to control the aspects that are different between each grid. A nice way to pass the arguments is to use jQuery.extend, which allows you to easily provide default argument values.
For example:
function myFunction(options) {
options = jQuery.extend(
{
myOption1: 'Default Vaule',
myOption2: 'Default Vaule',
},
options || {});
...
}

Resources