Is there a input field I can use to let the user edit dynamic JSON (large nested object without fixed schema)?
Or do I need to write my own?
You'll have to implement your own component for that
Related
I am using CallbackDataProvider<Object, Void> dataprovider and then setting dataprovider in grid using grid.setDataProvider.
Then in TextField addValueChangeListener method I am trying to call grid.getDataProvider() which is returning me CallbackDataProvider instance.
After that, I am trying to cast in ListDataProvider for filtering in which I am getting ClassCastException But when I am using PaginatedGrid getDataProvider is returning ListDataProvider instance.
Here I don't want to use PaginatedGrid, is there any way to convert CallBackDataProvider to ListDataProvider using Grid?
To answer your literal question, no, you can not convert a CallbackDataProvider to a ListDataProvider. Your underlying problem is stated between the lines here:
I am trying to cast in ListDataProvider for filtering
So your problem is that you want to filter the data, but the CallbackDataProvider doesn't provide a similar method for it as a ListDataProvider. There is a reason for this - ListDataProvider stores all of its items in memory inside a Java Collection, so it's straightforward to filter the backing Collection. A CallbackDataProvider is lazy-loading and doesn't know where the full set of items is, so you need to implement the filtering yourself against the backing data source.
To filter a lazy loading DataProvider, you'll need a ConfigurableFilterDataProvider. First, instead of creating your CallbackDataProvider with DataProvider.fromCallbacks, you need to use DataProvider.fromFilteringCallbacks. This enables you to use the filter of the query object and you can implement the filtering of your backend data as you see fit. Second, you'll need to wrap your DataProvider into a ConfigurableFilterDataProvider with dataProvider.withConfigurableFilter so that you can pass a filter object of your choosing.
You can find a full example here: https://vaadin.com/docs/v14/flow/binding-data/tutorial-flow-data-provider/#filtering-based-on-another-component
type Student struct {
name string `gorm:"fullname"` `json:"student_name"`
}
Will this work?
Is this allowed?
There is no problem, it is allowed as gorm and json use different tag name
Delivery data types and entity data types are highly recommended to be kept separate.
But can you do it? Yes. Does it work? Yes. Is it quick solution? Absolutely
Here is some question to answer if it is needed to be kept in one struct :
What happens if you add additional field to your data model?
Are others developers warned about this decision?
Are you okay with later time consuming refactoring?
But correct way to do it in my opinion is to separate models and convert them using mapper function.
From the documentation of QSortFilterProxyModel, the view should call "setSortingEnabled" to allow the user to sort the data and/or call sortByColumn.
I would like to use a filter to sort a non-sorted model data which is displayed by a QListView. Is there any way to achieve this?
Note: I am using PyQt4 but this should be a language agnostic problem.
As far as I can tell, there is no way to make QListView sorted using a QSortFilterProxyModel. I handle it by sorting the data in the (source) model directly.
I have a populated list, and I want to utilize a custom function to shorten row names which are too long to display. The rows from the list are generated from an object passed from the action/controller. How/where do I include my custom function for to achieve the above mentioned purpose?
Any advice appreciated.
I guess you need helpers:
http://www.symfony-project.org/book/1_2/07-Inside-the-View-Layer
Use this function in _toString method of the object to display its name.
Using the Enterprise Library 4.1 Validation Application Block, how can I validate that a collection property contains at least one item?
I'm assuming you mean out of the box. If so, then I don't think there is way to validate directly the number of items in a collection.
These are some other ways that you could try:
Decree that you only deal with null collections and not empty collections and use a Not Null Validator. Not practical, though.
Use self validation and have the object validate in code that the collection(s) have the correct number of items. Will work but it's nice to have the validation in the configuration file.
Expose the collection count as a property. This could be done, assuming an employee collection for example, with an EmployeeCount property on your object that contains the collection or you could create your own custom collections that expose a count property. Then you could use a Range Validator to validate on the Count property.
Create a custom validator that can validate the number of items in a collection -- something like CollectionCountRangeValidator.
If I wanted to develop something quickly, I would probably go with option 3. However, option 4 fits in well with the Enterprise Library approach and also allows your class design to be independent of the validation requirements. Plus you could always reuse it on your next project. :) And does anyone really miss creating their own collections when a List will do nicely?
This is already implemented in the EntLib Contrib.
This is called CollectionCountValidator.