Dgrid collection data not accessible after filtering on collection - dojo

So, I am using collection in my dgrid and the store is of type [Memory, Trackable]. I am using store filtering (as given here). When I filter the store data, then the returned collection object does not have any data attribute and thus I am unable to access the data from the collection. Although, the changes are reflected in the d-grid when I change the collection but I need to access the data from collection to do other things.
Here is my code:
var filterObj= new this.store.Filter();
var tagFilter= filterObj.in('tagList', selectedTags);
var newCollection= this.store.filter(tagFilter);
this.grid.set('collection', newCollection);
I am unable to retrieve data from newCollection as well as from this.grid.collection. Am I doing something wrong here?

The fetch (and fetchSync in the case of Memory) APIs are the correct public APIs to use (and that is why dgrid still has no trouble querying the collection).
data is an implementation detail, and you shouldn't really be trying to access a store/collection's data via the data property. That is ordinarily present on the root store when it gets mixed in via constructor arguments.

Related

How to regularly update mongoose db in express js without req

I want to retrieve 'Content' instances sorted by a ranking factor, which changes by likes, dislikes and time. First solution I came up was adding 'ranking factor' virtual field on the 'Content' model, but mongoose didn't allow me to sort the instances by the virtual field when retrieving them. So the only solution I have now is adding 'ranking factor' field on the model and update all content instances regularly using setTimeOut function of node js. Then where should I add setTimeOut function in express js structure?
I considered adding setTimeOut(2000, // update all content instances here) on app.js file, but there was a feeling that it is not somewhat right. I'm planning to add the codes like below.
setTimeOut(2000, Content.findAndUpdate(*, {rankingFactor: calculateRankingFactorWithTime(window.currentDate, this.likes, this.dislike}))

Graphql and access to Types Properties depending on some logic

I am new to Graphql and some things still confuse me.
I am working on a project, similar to Todo List.
User may have multiple todo items, some of item's properties must be visible to owner only, some should be public.
So far I came up with two ideas:
1) First is to create two separate types, something like:
ToDoType {
id
name
complete
}
ToDoPrivateType {
id
name
complete
colorGroup
createdAt
...other private properties
}
And access
- ToDoType from root query user {...} and everywhere else, except
- viewer {...} where I will use ToDoPrivateType
It will work but looks a little like double-work,
plus if I retrieve todo lists from standard user root query I will not be able to pull private properties for user's own user.
2) I can also provide access to all properties and set to null properties to which a random user should not have access (like createdAt of other's users) but it also does not look right.
Hope what I am asking is not too confusing.
Do these approaches make sense?
Is there a better way to control access to some properties?
Thanks!

Can we send multiple Properties in Json of Analytics(IBM MobileFirst)

I was asked for a usecase where I have to filter ActionEvents on type of Page that action is being is being called from.
Example
use case: I have a login page and I have to capture analytics of its events
Can I do something like this
String json = {"PageLevel":"LoginPage","ActionLevel":"LoginButton"};
WLAnalytics analytics=new WLAnalytics();
analytics.log(message, new JSONObject(json));
Will this work... can we create custom chart with first property being ActionLevel and filter it as per PageLevel.
No this will not work. Custom analytics can only be logged in key value pairs i.e. you cannot send two key value pairs in one JSON object. This is a good idea though, I recommend you submit an RFE.
Submit a Feature Request

Data not updated in dhtmlx .net scheduler

I have problems and questions about this scheduler. I already tried to build and almost finished it. Although, I receive some errors...
What I do?
I create custom lightbox
mapping all the data in to table dbo.bEvent
I used custom eventbox like this : Scheduler.Templates.event_text = "({position_desc})" + " " + "{newrate}"
position_desc is actually from other table 'dbo.zone'
I create Views in SQL Server to retrieve data from 'newrate'. 'newrate' actually is a new attribute after I do some query to change rate "1000 to 1k" which is new rate save '1k'.
the views that I create by joining table "dbo.zone and dbo.bEvent"
Problem is?
when I save a new data or insert or update new data. my event box just give me '(Undefine)undefine'
all the data that i put in lightbox is save in dbo.bEvent
after I resfresh the page using f5 or navigate to next page or previous page then the data is updated.
Here i attach some screenshot. Thanks in advance
http://s1319.photobucket.com/user/matpyam/library/?sort=3&page=1
If you save the changes as described here http://scheduler-net.com/docs/lightbox.html#define_crud_logic ,
note that the method uses SchedulerFormResponseScript class to render the response.
Constructor takes instance of the event class to be returned to the client. Values of that event will be applied to the related event on the client-side
return (new SchedulerFormResponseScript(action, changedEvent));
make sure object that you send (changedEvent) has all data properties initialized. Basically the event should have the same data as when it is loaded from the Data action.
Alternative solution, which may be more straightforward, would be reload calendar data with the client-side api after saving event:
scheduler.clearAll();
scheduler.load("dataUrl", "json");
http://docs.dhtmlx.com/scheduler/api__scheduler_clearall.html
http://docs.dhtmlx.com/scheduler/api__scheduler_load.html

Combining DataSource and Local Data in SmartGWT ListGrid

I have extended a ListGrid to create a list of saved searches grouped by type of search, whether public or private. This list is populated through a standard SmartGWT datasource.
In addition, I would like to add to this list a grouping of historical searches, that would be available to a user as they create searches on a session-by-session basis (IE. a user creates a new search - until they close the browser, that search will display in the search list, under the grouping 'Historical Searches').
Long story short, I would like to be able to populate the ListGrid from two separate sources - from the already existing datasource and ideally from a RecordList saved in memory. I tried something similar to this:
#Override
public void fetchData() {
invalidateCache();
discardAllEdits();
super.fetchData();
setCanEdit(true);
for(Record r : histSearches.toArray()) {
startEditingNew(r);
endEditing();
}
setCanEdit(false);
markForRedraw();
};
While this code does get executed, it does not in any way perform the functionality that I'm hoping for it to do. Does anybody have any suggestions on how to perform this functionality? Any help would be greatly appreciated.
If you call DataSource.fetchData(), in the callback you can get the selected data as a RecordList. You can then add your per-session searches via recordList.add(), and provide the modified RecordList to a ListGrid via setData().
By the way, there is also an article on the public wiki showing a sample implementation of saved search (though different from what you want):
http://wiki.smartclient.com/display/Main/Saved+Search+%28Smart+GWT%29