Multiple views over a single Kendo data source - kendo-ui

Using the Kendo DataSource am I able to create more than one view over a single data source.
To take a simple example say I had a list of people in the dataSource and I wanted to bind this data source to two list views, one list sorted ascending and one sorted descending, is that possible.
In a view/modal API one would expect the view to be separate from the model precisely so one could have multiple views over a single model. With Kendo it appears to be a one to one relationship. Am I wrong?

You can have multiple controls share a DataSource, as seen on the Shared DataSource demo page.
I also recall hearing of one DataSource wrapping another DataSource, allowing the two to sort differently. I can't find a link for this right now though.

Related

Ember sorting/filter table

I am looking to add a filter/sorter table into the application. I need to choose which column can be sorted - and provide change of class glyphs up/down arrows on the columns. The filter box also needs to be outside of the table.
I tried looking at this example, but there are no glyph class changes on the cols and the filter box is inside the table.
http://crodriguez1a.github.io/ember-sort-filter-table/
I looked at this custom solution, but I couldn't see a way of locking the filter to specific cols.
http://www.jarrodctaylor.com/posts/Filter-And-Sort-Tables-In-Ember/
http://emberjs.jsbin.com/yezonaxu/12/edit?html,css,js,output
what about this one -- http://onechiporenko.github.io/ember-models-table/v.2/docs/classes/Components.ModelsTableRowFiltering.html
but the problem here - is how to create some custom markup depending on the data.
You could sort and filter your rows using computed properties. For sorting you could use sort macro. For filter you should implement your own logic, cause filter and filterBy macros does not support observing a value used to filter the array. Use the sorted and filtered rows to generate a simple HTML table or pass it to a table component of your choice.
If you will take DataTables and wrap it in ember component (custom code would work better that some generalized 3rd-party wrapper), you can achieve a lot. Including filtering by columns. It's a bit hard way, though - DataTables is big and it's API is a bit complicated. That's if you want client-side filtering.
For server-side filtering approach would be different - you render UI for filters using ember's methods, convert user's choices to string and pass that to API (which should be modified to support filtering) when asking for data.

Sorting by column in an XPages view data source

I have a dynamic view control (my own) which is fed by a configurable view data source. I need to be able to sort the view by various columns. Is there a way to do it with the view data source or do I need to roll my own? Thanks for the help.
For efficiency reasons, sorting should be handled by the domino runtime. The view must have the right columns either tagged as sorted or sortable by user. This creates the indexes within the NSF.
Then, the data source has some properties to control with sort index in being used, based on the name of the column you want to sort. The extlib DataView controls shows how this can be done in Java, through a JSF DataModel.
Also, you might consider using the DynamicViewpanel from the extlib/up1, as it does all of this for you.

Core data, bindings, NSArrayController and table views - how to generate a view of a core data context

I have a working system that lets me build a database containing instances of various entities , all linked together nicely.
Before I knew I would care, I came across a tutorial on using Core Data and bindings, and it went through a complete case where you get a table showing all the entities of some type with a column for each property. It showed both the UI side and the Data model side - not that I need the data model part at this point. Now, darned if I can find it. This is one of those things that is supposed to be easy, and requires virtually no code, but getting exactly the right connections in UIBuilder is not going to happen if I can't find instructions.
Also, I thought I came across an example of something like a query editor where the user could select which properties to sort on, which to match on, etc. Did I imagine that?
Anyone out there know where I can find such?
Sure, you can do this without code:
Add an array controller to your nib.
Bind or connect an outlet for its managed object context
Set the array controller to Entity mode, fill in the entity name, and select Prepares Content.
Bind your table view columns to array controller's arranged objects, and fill in the key name for the model key.
Regarding the query editor, open up the model, and on the Editor menu click Add Fetch Request.
I found at least a partial answer to the query editor question, in this apple tutorial. Not sure how far it will get me, as I prefer to write code where possible, since then I can leave a trail of comments.

Core data: can NSFetchedResultsController fetch two different entities?

I am working on an iPhone app, and in a particular view I need to load two different entities: One that will populate a UITableView, and another that will populate a UITextView.
Is it possible to fetch both properties using a single NSFetchedResultsController?
Or do I need to use two different NSFetchedResultsControllers?
Any ideas on how to best approach this problem?
Each fetch request has only one entity and each fetched results controller has only one fetch. Therefore, you need separate controllers for each entity.
If you think about it, how would you make a predicate to fetch two logically separate entities?
You probably don't need two fetches at all. In most cases, you can fetch the entities that populate the table and then use a relationship for the entity of the selected row to populate something like a text view.
Best solution would be to refactor your Model and see if your 2 entities have something in common. You can make an abstract entity for the intersecting stuff, then inherit your 2 entities out of that. Perform the fetch on the abstract entity, and your fetch results controller should return mixed results.
As TechZen stated, the answer is no.
However, you can monitor the saves of the NSManagedObjectContext yourself and react to those saves. If you really do need to watch more than one entity (something that is far more common on the iPad than the iPhone) then add a NSNotification observer on the NSManagedObjectContextDidSaveNotification and look at the -userInfo of the NSNotification that comes back. You can then run predicates on against the results to determine if you need to update your display. That is what the NSFetchedResultsController is doing under the covers.
The quick answer is NO. But I found a creative answer.
In your tableViewController, make a search bar with how many scopes you have.
When different scope is selected, you can fetch different entities!
This works because I made an app like this!
Users would have easier time separating the two different data too!

Filter/Sort in the view or in the model?

Having a list of data object and something visual to represent each, where would you code the sorting/filtering logic? Why?
Edit : All the answers so far are good, but I forgot to add another constraint. What if I don't want to reconstruct the view each time?
The answer lies in the data. The model delivers the data. If all the data is in the view, the filtering and sorting can be contained within the view. If the data is chunked, the model must deliver the data and contain some of filtering/sorting (the view may still contain filtering/sorting as well).
The controller should not contain these functions, since it is a routing mechanism and should not have any idea of how to interpret the data.
Depends on the complexity of the sort/filter operation and whether the view control offers those services natively. If the view control offers filtering and it's simply reformatting the in-memory data then leave it in the view. If the sort/filter requires another trip to the data source then keep it all in the controller.
I would put in the sorting and filtering methods in the controller, and call these methods from the view.
Your View should only handle displaying the output. Put any filtering/sorting into your business logic and return it to the view.
I believe the sorting should be something separate. You should not sort in the model because you want to keep it as-is. Basically, a change in the model implies a re render of the view and you probably do not want that (if you want to animate a transition between the pre and post filter states, for example).
What I would suggest is that the model provides the data to create both a list of visual objects for the view and a sorter object. The sorter object would output a render list which would simply be a list of some identifier linked to the visual objects (index in objects list or other). The order in which the IDs appear represents the order of the sorting and any ID not in the render list is hidden. Every time the view receives a render list, it would update it's display.

Resources