I want to sort multiple columns at a time programatically. I am NOT using the default sorting method which is to click on header name to sort and ctrl/shift key + header name to sort multiple columns. I have a different option in the column options menu which is used to sort that specific column. For single column sort, I am using the following api.
params.api.setSortModel([
{
colId: params.column.colId,
sort: "asc",
}
Is there any api or anyway to sort multiple columns?
You need to construct a sortModel object which looks like this -
var sortModel = [
{
"colId": "athlete",
"sort": "desc"
},
{
"colId": "country",
"sort": "asc"
}
]
Then you can use the sorting api, the way you have used it and pass this model which is just an array containing more than one column instead of single column the way you have it in question
params.api.setSortModel(sortModel);
Example on sorting api.
Related
I have a lookup activity (Get_ID) that returns:
{
"count": 2,
"value": [
{
"TRGT_VAL": "10000"
},
{
"TRGT_VAL": "52000"
}
],
(...)
I want to use these 2 values from TRGT_VAL in a WHERE clause of a query in another activity. I'm using
#concat('SELECT * FROM table WHERE column in ',activity('Get_ID').output.value[0].TRGT_VAL)
But only the first value of 10000 is being taken into account. How to get the whole list?
I solved by using a lot of replaces:
#concat('(',replace(replace(replace(replace(replace(replace(replace(string(activity('Get_ID').output.value),'{',''),' ',''),'"',''),'TRGT_VAL:',''),'[',''),'}',''),']',''),')')
Output
{
"name": "AptitudeCF",
"value": "(10000,52000)"
}
Instead of using big expression with lot of replace functions, you can use String interpolation syntax and frame your query. Below is query which you can consider.
SELECT * FROM table WHERE column in (#{activity('Get_ID').output.value[0].TRGT_VAL},#{activity('Get_ID').output.value[1].TRGT_VAL)
I'm using Postgres/sequelize .
I need to do bulkupdate and the table is partitioned , so I can't use "Insert into ~ on conflict" .
It looks like I can use bulkCreate with 'updateOnDuplicate' option but I don't know how to define multiple keys. I mean there is no pk in the table but I know two columns together will make unique records.
In this case, how to do bulkupdate ?
Model.bulkCreate(dataToUpdate, { updateOnDuplicate: ["user_id", "token", "created_at"] })
In my case I was using json object array in my model indexes fields like name value pair which was causing issue, after updating it to array of strings fixed my issue in seqialize version 6.
indexes: [
{
name: "payment_clearance_pkey",
unique: true,
fields: ["payment_module_id", "account_id"]
},
]
I'm trying to find a way to implement the relay-style cursor based pagingation using Postgresql. In this scheme, I would order my results based on certain criteria on a number of columns. After I get the results, I would use the columns values for each retrieved record to build a cursor for each record.
My question is:
If I have a record with column values such as this:
[ { lastName: "Turing", age: "50", id: "100" } ]
and it was retrieved with an order such as this:
[ { lastName: "asc", age: "desc", id: "asc" } ]
If I save this criteria and ordering by which a record was retrieved, is it possible to get all the results that would come after the record in this ordering even if the given record itself was deleted?
I was thinking to use the rank(), but I think it breaks paging when records are deleted.
Each element in collection has following format:
{
"Name": "Some Name",
"Description": "Some description",
"Tags": ["java", "code", "some tag"]
}
I have created index on field "Tags" as follows:
db.Establishments.ensureIndex({ Tags: 1 });
Now I want to make query to find out all the tags that begins with "ja" for example (for auto-complete suggestion).
Instead of querying collection is there a way to query index directly, or efficient query which involves operation on index only?
I suppose that you actually want to query the tag attribute and return distinct values for your autocompletion feature, right?
This is quite easy using the distinct method:
db.Establishments.distinct( 'Tags' )
See http://docs.mongodb.org/manual/reference/method/db.collection.distinct/ for more info on distinct queries
As to your question about index queries: you can't ask an index directly - the index serves query optimization as such. Using distinct on an indexed attribute will be quick.
To query the distinct method, execute:
db.Establishments.distinct( 'Tags', { 'Tags': /^ja/ } )
I created a row repeater. The row repeater template consists of a panel which consists a table.
I have set a model for the row repeater and the tables uses that same model, but with a different path.
The model for the rows of the row repeater as a property LEVEL. Now I want to show in the tables for the rows only the values with the same level. So I tried tried to filter for that value like that:
oTemplateTable.bindRows({
path: "/ROOT_COMPONENT",
sorter: new sap.ui.model.Sorter("NAME"),
filters: [new sap.ui.model.Filter(
"LEVEL",
sap.ui.model.FilterOperator.EQ, "{LEVEL}")]
});
But this did not work. I need some way to get the level value for the row in which the table is in. Has anyone an idea?
Both ROOT_COMPONENT and ROOT_STATISTICS are objects (i.e., {{data},{data}}) containing objects instead of arrays (i.e., [{data}, {data}]) containing objects, so I doubt you will be able to render the RowRepeater correctly
Furthermore, I think the {LEVEL} argument in your filter resolves back to ROOT_COMPONENT (since that's where you're binding your table to) and not ROOT_STATISTICS.
I think you could save yourself a lot of trouble if you could rework your JSON response to a more hierarchic one, so you won't need a filter anyway:
[{
name : "ABC",
tableData : [
{
amount : 20
}]
},
{
name : "DEF",
tableData : [
{
amount : 1
}]
}]
This way you just bind your rowrepeater to the root node, and your table to the relative child tableData