JSF selectOneMenu not whole List - list

Is it possible to choose only specific items from the list in selectOneMenu?
For example. I have List Products has many fields like name, id etc. One of it is category (1,2 or 3) I want to have only one category in the selectOneMenu without making new Lists and new classes. Can you help me?

I think the easiest way is to set the value attribute of f:selectItems to a method which filters your original collection.
Otherwise you'd have to implement your own version of f:selectItems which allows filtering - as we once did in one of our projects.

Related

Ordered ManyToMany relation in Django with custom Field

In Django, I would like to have an ordered many-to-many-relation. Assume I have, say, the models OrderedList and Item, and I want to be able to insert Item()s into an OrderedList() at a specific index, I want to be able to retrieve the Item()s of an OrderedList() in their order and also to change the order of Item()s on an OrderedList
I already found Define an order for ManyToManyField with django and https://github.com/gregmuellegger/django-sortedm2m
Both the github repo and the accepted answer in the SO question are working with the same architecture: They create an additional integer field, say order_index, on the junction ("Through") table which represents the position of the Item() on the OrderedList().
Honestly, I do not like that too much. If I see this correctly, having the order stored on the junction table can create inefficiency when I want to reorder Item()s: Imagine, I want to change the position of an Item() on an OrderedList() which has n Item()s. This means O(n) database updates to reorganize the order indices.
I would like to avoid this. I think of an architecture where I have an ordinary many-to-many-relation and one additional column on the OrderedList table which holds a list of Item ids, say items_order. In this architecture, I need one database update and one list operation on items_order - which should be way faster, I guess.
I believe the best way for this is to create a custom model Field. The docs state how to create a custom model Field (https://docs.djangoproject.com/en/2.1/howto/custom-model-fields/) and I can create my items_order field like this. But I did not find how to make a custom Field which, besides creating the order_list, also creates the junction table and takes care of updating the items_order whenever a new related Item() is added or removed from the relation. I think, I should subclass the ManyToMany Field (https://docs.djangoproject.com/en/2.1/_modules/django/db/models/fields/related/#ManyToManyField). But I don't know how to do this, so could you give me some guidance here?

Basic List on Entity Form

In Dynamics CRM online, I can add a list of entities to another entity, for example a list of products to an opportunity.
Is there any way I can have a list that is not picked from pre-populated items, e.g. just a simple list of {number, date, text} that you type in each time you want to add to the list, not picking items from a pre-defined list.
I am just using the web interface to customise at the moment, but I am open to any suggestions.
EDIT:
So far i have;
Created two entities, proposal and proposal version
Added a 1:N relationship between proposal and proposal version
Added a sub-grid to the proposal form, tried to make it editable but it refuses to work
This lets me add new rows by opening up the proposal version form and adding a new one or picking from already created ones for other proposals but that is rather clunky for a simple list.
I don't want it to offer to search for previous entries, just let me add to the list by typing stuff in, surely this should be fairly simple?
If you want a pre-defined list of items that are simple (number, date, text..) then you can create an option set field in CRM. These lists are fixed and can only be extended by customising the system. An example option set field might be Organisation Type:
Prospect
Site
Head Office
...
If you want a pre-defined list that can be extended, you need to create a new entity. Following from the previous example, you would create a custom entity called Organisation Type and then create a record for each type you wanted, populating only the name field with the type: Prospect, Site etc.
Then you would add a lookup field pointing to the Organisation Type entity on any other entity that used the field, such as Organisation (Account).
You see how the custom entity still appears as simple data because you're only populating the name field, which can be text, a number etc. You can also apply security roles to this entity, limiting which users can create and delete options from your list.
Edit: to only allow the creation of new records in a subgrid, make sure the lookup attribute to the parent entity on the child entity is business required.

Django Inline with join table structure

So I have a DB structure like so: (ignore how i named things its a quick fake DB example things)
Collection: id, ...
List: id, title,...
Car: id, name, ...
CollectionHasList: id, collectionid, listid
ListHasCar: id, carid, listid
So what I am trying to do is in the django admin panel under collection/add I want to be able to fill in all of these tables instead of filling everything in individually one by one.
So the collection fields will exist as normal, but then I want to have a custom field that takes in a list title and a text area that takes in a comma delimited cardIds (cards are already created and don't need to be done through here, just list and collections) But since Collections have many lists, I want to be able to click a "add" button and generate the same custom form again to add more lists (with associated cars).
I think in the model I will be able to do the custom saving that I need, but I can't get the form to work and thats what I need most help on. Can anyone please help me! Thank you so much! I looked everyone on stack overflow and haven't found anything that can directly help me, some good points, but I still can't put it together.

Sharepoint: Establish related records when new item being added to list

What is the best way to implement a parent-child hierachy between items in a list? The requirement is as follows
-> there is a list item with a particular ID
-> that particular ID could have related records.
-> all those related records should show up when viewing the list item
When the user adds a new item to list using a form, they should have the option to choose whether the new item being added has another related item or not.
The primary question here is what would be the best way to establish this hierarchy in the list? Also, all the items would be in the same list so how
would we link the list to itself? Or, what would be the best way to implement this? I can figure out several approaches to handle this within the confines of the
sharepoint server object model; however, this needs to be done primarily within the UI of Sharepoint itself (webparts, features, etc. may be used). However,
I am not sure how to IMPLEMENT THIS WITHIN THE SHAREPOINT CONTAINER ITSELF.
Any ideas/insights would be greatly appreciated.
Thanks
You can create a look up column in list with a parent list as itself and allow multiple selections. That way you will be able to check multiple parent IDs for a specific list item.
To show related list items, you can customize details view page of the list in sharepoint designer and add list view web part or dataview with appropriate filters based on the current item.

How do you get child bands in ultragrid without using related tables in a dataset?

I'm using linq to pull back an object (i.e. customer) that might have a collection of other objects(customer.orders). I would be nice if I can pass this list of customers to the ultragrid and a hierarchical view of customers and thier orders displayed on databind. When I try this, I just get customers. Anyone know how to get this to work with non dataset objects?
Figured it out. IList collection works and will create bands for properties of your domain object if it is an IList<T>. Just make sure thatDisplayLayout.ViewStyle = ViewStyle.MultiBand.
I've tried the following and it didn't work:
DisplayLayout.ViewStyle = ViewStyle.MultiBand
I read from this blog that it must be List and not IList in order to work, and it did.
We work with our own custom datasource for grid, so we first create a structure of bands and then we initialize data OnDemand, handling events
InitializeDataRow
InitializeRowsCollection
CellDataRequested
We use Tags to navigate through the structure.