I have a list like this: (it will generated by a for loop, and each row is related to a unique ref : ref="'dataRow'+id" )
<GridLayout class="mainList">
<ListView
for="( sentence , id ) in sentences"
><v-template><StackLayout>
<GridLayout
class="dataRow"
:ref="'dataRow'+id"
#tap="tapAction( 'dataRow'+id )"
>
...
</GridLayout>
</StackLayout></v-template></ListView>
</GridLayout>
I would like to expand each row of Data by tapping on it, and I acheive that by this piece of the code:
tapAction ( dR ) {
this.$refs[dR].nativeView.animate ( {
height: 300 ,
duration: 200 ,
curve: enums.AnimationCurve.easeIn
} )
}
(BTW I noticed it expands multiple rows!! I think it is related to the nature of ListView but it seems a bit bizarre to me while I used unique ref for each row of data! any suggestion for this issue would be helpful, but my actual question is something else.)
my problem is this:
I woud like to collapse all expanded rows at once , but I can Not find a proper way to do that! my first thought was that to set all elements by the dataRow calssName to the default value, but I can Not do that as simple as we can perform in a web browser with css + js.
Related
I have a table that looks like this:
What I want to do is convert it to a JSON that has all distinct years as keys, and an array of Make as value for each key. So based on the image, it would be something like this:
{ "1906": ["Reo", "Studebaker"], "1907": ["Auburn", "Cadillac", "Duryea", "Ford"], ... }
Could someone please help me on how to write a query to achieve this? I've never worked with converting SQL -> JSON before, and all I know is to use FOR JSON to convert a query to JSON.
I managed to solve this for whoever needs something similar. However, I think this way is inefficient and I would love for someone to tell me a better method.
I first ran this SQL query:
WITH CTE_Make AS
(
SELECT [Year], [Make]
FROM VehicleInformation
GROUP BY [Year], [Make]
)
SELECT
( SELECT
[Year] AS Year,
STRING_AGG([Make],',') AS MakeList
FOR JSON PATH,
WITHOUT_ARRAY_WRAPPER)
FROM CTE_Make
GROUP BY [Year]
This gave me the JSON in a different format from what I wanted. I stored this in a file "VehicleInformationInit.json", and loaded it in JS as variable vehicleInfoInitJsonFile and ran the following code in JavaScript:
var dict = {};
$.getJSON(vehicleInfoInitJsonFile, function
(result) {
result.forEach(x => {
var makeList = x.MakeList.split(',');
dict[x.Year] = makeList;
})
var newJSON = JSON.stringify(dict);
});
I simply copied the contents of newJSON by attaching a debugger into my required file. However, you can easily use fs and store it in a file if you want to.
i used Apollo in ReactNative Project
i want get some products from server with Query component in ApolloClient , my query schema is some thing like this
products(isExisting:true) {
id
name
}
this Query give me all available products and also i have this query too with different Argument
products(minPrice:$price)
id
name
}
now i want create program for conditional for choose between 2 Arguments , in Plane [A] use (isExisting) arg and in Plane [B] use (minPrice)
my first and stupid solution is create 2 different query component , is it any other way , for example set Variable for arguments like this
products($choose:$value)
also i know about directive in graphql https://graphql.github.io/learn/queries/#directives
but i think this is just for field
also my second solution for resolve this put javascript variable in `` , like this
render() {
const arg = 'minPrice';
return(
<Query
variables={{ }}
query={gql`
query {
products(${arg}:100) {
id
name }
i am checked this , working well for me , but i want know this is good and better way
I think last solution , is good idea for doing this approach , also you must know directive just working for filed
products(isExist:true) {
name #include if(false/true)
}
this means if conditions return True you get ( name ) field and if return False , ( name ) field not included in your query
also you can this directive
products(isExist:true) {
name #skip if(false/true)
}
#include(if: Boolean) Only include this field in the result if the argument is true.
#skip(if: Boolean) Skip this field if the argument is true.
I am trying to create a dashboard that consist from two components: CCC Bar chart and Multiple select component.
I use the multiply select component for assignment param value, which is using in the datasource. (MDX query):
SELECT
NON EMPTY {[Measures].[doc_count]} ON COLUMNS,
NON EMPTY {[Dimension Usage date_publish.Hierarchy date_publish].[date_publish].Members} ON ROWS
FROM [Docs]
WHERE CrossJoin({${param_hosts}}, {[event].[active]})
So if I set (multiply select component) property value array with pairs:
( {arg:[host].[news.com] value:news.com}, {{arg:[host].[somesite.com] value:somesite.com}} ), everything work perfect.
The parameter is bound to the component receives the correct value, for example: [host]. [News.com], [host]. [Somesite.com].
But if I try to fill the multiply select component from the datasource it become unworkable.
As DataSource, I use the sql over sqlJndi with query: SELECT distinct (host) as Id, concat ('[host]. [', Host, ']') as Value FROM docs_fact where dim_event_id = 1;
The result this query is a table:
id value
news.com | [host].[news.com]
somesite.com | [host].[somesite.com]
Parameter is assigned a value: news.com, somesite.com
Changing the properties of the Value as id only affects which of the fields (id or value) will be shown to the user, and the parameter's value is not affected.
Tell me please, is it possible to specify which of the columns to be used for display to the user and which of the columns to be used to generate results?
No, but you can change the dataset on the clientside using the postFetch function on the multi-select component.
function (dataset) {
for (var i=0; i < dataset.resultset.length; i++) {
var temp = dataset.resultset[i][0];
dataset.resultset[i][0] = dataset.resultset[i][1];
dataset.resultset[i][1] = temp;
}
return dataset;
}
Or similar
When using an order by, conditional projection and SetFirstResult() together in a query I get this error:
Invalid index 4 for this SqlParameterCollection with Count=4
In my experience, this error usually happens when you have one field mapped to two properties, as outlined here. But it is not the case in this situation, the query works fine until, I pass a value greater than 0 to SetFirstResult().
This bug logged with Nhiberbate seems very simular, but it was fixed 2 years ago.
Any suggestions on how to proceed? Here is a sample of the code:
var query = Session.CreateCriteria<KeepItem>(KeepAlias)
.CreateAlias("Resource", ResourceAlias)
.CreateAlias("Memory", MemoryAlias, JoinType.LeftOuterJoin);
// other code
query.AddOrder
(
Order.Asc
(
Projections.Conditional
(
Restrictions.IsNull(MemoryAlias + ".MinDate"),
Projections.Conditional
(
Restrictions.IsNull(ResourceAlias + ".MinDate"),
Projections.Constant(DateTime.MaxValue),
Projections.Property(ResourceAlias + ".MinDate")
),
Projections.Property(MemoryAlias + ".MinDate")
)
)
);
//other code
query.SetFirstResult(skip);
query.SetMaxResults(take);
return query.List<KeepItem>();
I wanted to persist window position. But the case is windows id are dynamic.
Here is the detail scenario..
dynamic_id will be one of "id1", "id2" ... "id5"// these are fixed
window.openDialog("chrome://something/content/test.xul, name, dynamic_id)
and my test.xul is
<window persist="screenX screenY" ..... >/<window>
Now how could I achieve persistance of window.
I tried adding
window.id = dynamic_id, But it doesn't works..
Or If there is a way to do something like below:
<window id = "dynamic_id" persist= ..../></window>
Thanks in advance!!
that is becuease the url is always the same, and this is the "id" that mozilla use to remember "the persisting things" in its database of "persisting things".
Do this:
openDialog("chrome://something/content/test.xul?id=" + dinamic_id, name )
then in your text.xul, you have to obtain the id, do this:
id = location.search.match( /id=([^&]+)/ ) && RegExp.$1