I'm sure everyone already knows this, but it took me a while to figure out so I thought I would share.
Basically I was trying tell a widget to change color based on the current status of an entry in my model.
But I needed Widget 1 to change for Room 201, Widget 2 to change for Room 202, etc.
Ex:
Room: 201, Status: Available = Widget 1: Green
Room: 202, Status: Booked = Widget 2: Red
I could get the widgets to change color (thanks to borrowing from the code in the Project List Sample), but I was confused how to change their individual datasources to a query. They would basically only show the color corresponding to the currently selected item in the database/table.
So, here is what I did:
Went into my Model, went under Datasources and added a new Datasource.
Ex name: Room201
Then in the Query builder I put in the Field I was trying to narrow by.
ex: Room = :Query
(Room = my field, and I believe the ":Query" is the just name of the query, someone can correct me if I'm wrong)
Then you'll see a box below that window where you can add a binding. So THAT is where I put in my query.
ex: #datasources.Facilities.query.filters.Room._equals = 201
(Note: I had to create a separate Datasource for each room)
Then I went to my widget and chose the queried datasource (Room201) for the datasource.
So Widget 1 = the datasource Room201, Widget 2 = the datasource Room202, etc.
Done.
Hopefully that helps someone!
Posting the author's (Adam Bergeron) solution to the question as an actual Stack Overflow answer:
"
So, here is what I did:
Went into my Model, went under Datasources and added a new Datasource.
Ex name: Room201
Then in the Query builder I put in the Field I was trying to narrow by.
ex: Room = :Query
(Room = my field, and I believe the ":Query" is the just name of the query, someone can correct me if I'm wrong)
Then you'll see a box below that window where you can add a binding. So THAT is where I put in my query.
ex: #datasources.Facilities.query.filters.Room._equals = 201
(Note: I had to create a separate Datasource for each room)
Then I went to my widget and chose the queried datasource (Room201) for the datasource.
So Widget 1 = the datasource Room201, Widget 2 = the datasource Room202, etc.
Done.
Hopefully that helps someone!
"
Related
Dears,
I'm using Microsoft Dynamics AX2012 R3
The Case: I want to make a custom lookup in Inventory Management ==> Journals ==> Item Transactions ==> Movement ==> Lines
I want to relate the Item Id to show all lines in the SalesLines Table in order to get the ItemId and It's dimensions (Config/Size/Color/Style) and when I select it I want to move the selection to the movement line.
My Solution:
Step1: I've made a custom view (viewCustomItemId) that shows all SalesLines tables and related to InventDim to show the dimensions.
Step2: I've made a custom form (frmCustomItemId) and added the view (viewCustomItemId) as a datasource and added all fields to a grid
Step3: In the form (InventJournalMovement) I've overrided the lookup method and added below code
Args args = new Args();
viewCustomItemId _viewCustomItemId;
args.name(formstr(frmCustomItemId));
args.caller(element);
newPopup = classFactory.formRunClass(args);
this.performFormLookup(newPopup);
newPopup.init();
newPopup.wait();
if (newPopup.closedOk())
{
_viewCustomItemId = newPopup.docCursor();
InventJournalTrans.ItemId = _viewCustomItemId.ItemId;
InventDim.configId = _viewCustomItemId.configId;
InventDim.InventSizeId = _viewCustomItemId.InventSizeId;
InventDim.InventColorId = _viewCustomItemId.InventColorId;
InventDim.InventStyleId = _viewCustomItemId.InventStyleId;
InventJournalTrans_DS.research();
}
Problem: When the lookup form is closed all fields are set to the movement line but I get warning message (Field 'Item number' must be filled in.) and the line number in the database are set to be minus for this line and also the default site and warehouse for this Item is not automatically set.
Question: Looks like I've retrieved the values but didn't pass it correctly to the lookup of the field, I don't understand what exactly I missed to make it work normally.
Thanks in advance.
I'm surprised I missed this at first glance.
This line is your problem:
InventJournalTrans_DS.research();
You're researching before you've updated/written the data. I'm not sure why you're researching in the first place, but you have to do one or the other. Write/Update, then research or don't research. The research is where you're losing the ItemId you've input.
I am (still) working with Vaadin 7.6.4 and im trying to write my own custom FieldGroup.CommitHandler
I am trying to retrieve the currently added item (grid row) from the the commitEvent itself.
While debugging I can see that all the Data is available in a property called itemId if I use the following trainwreck: commitEvent.getFieldBinder().getItemDataSource() inside the Debug-Inspector, however it is private.
The itemId is the exact bean-entity i want to access. I only managed to access single fields of the entity with the following trainwreck: commitEvent.getFieldBinder().getField(propertyId).getValue(). However this is cumbersome and does not give me the entity as a whole (and to be precise does not retrieve the information from the entity, but rather from the displaying elements of the grid).
Is there a way to access the currently edited entity (which is the datasource for the edited grid row), without declaring the entire grid as a global field and call the grid.getSelected()-method?
Also, is there a data-wise difference between post- and preCommit?
Since you are apparently using BeanItemContainer based on your comment of itemId, You could try something like the following:
BeanItem item = (BeanItem) commitEvent.getFieldBinder().getItemDataSource();
MyBean bean = (MyBean) item.getBean();
getBean() in this case returns itemId.
[google-app-maker]
New to AppMaker and never done coding before, so please excuse the question if obvious or I'm trying to do the impossible.
App Maker -
I have a page,
on the page is a 'Create' Item form,
and then on another panel on same page, a dropdown from another model thats generated from a 'one relation end' and using a none related datasource or model to the model I am updating.
Like me my code is very simple(as learning) Im just trying to update a field within the model the form is creating a new item in with the current dropdown value, that comes from a different datasource and based on a 'one relation end' from two other tables.
Table:
Id | date | action | user | note | theValue |
'did it' X
I have applied the code within my 'Submit button' on the form, to keep it very basic.
widget.datasource.item.action = 'did it'; // Works fine
widget.datasource.item.theValue =
widget.root.descendants.Sites_dropdown.value; // this fails ( error below )
widget.datasource.createItem();
But I get the following error.
ERROR --
Type mismatch: Cannot set type sites record for property newValue. Type String is expected.
at assets_move.Content.Form1.Form1Footer.Form1SubmitButton.onClick:2:33
I can see by the error, its not passing as a string, not sure if this is because its a dropdown with a different datasource on another panel, or Im using the wrong binding to get the value.
Any help much appreciated.
The problem is likely that the value binding you have in the property editor of the Sites_dropdown widget is not a string, make sure it is a string binding and it should work. Also, with a binding, you will not need this anymore:
widget.datasource.item.theValue =
widget.root.descendants.Sites_dropdown.value;
Since the binding will handle that for you.
You may also have the Options property of the widget set to a record, and thus the value is also a record. Make sure options is also a string and not a record.
I would like to have the user enter order items on my order form as a table where they input the Qty and Prod #. I've not programmed with that type of field so a blank line would initially display for a new order. They would type a Qty and an item number in the fields and hit enter. When they hit enter from either field, what do I program to check the validity of the two fields. Plus I need the item number to be a drop down/type ahead field. Does anyone have an example of this type of thing they could send me? It would be looking at a view in the product catalog db. Also, after they enter an item to order, that "doc" should get stored/saved and a new blank line should open up.
What type of control do I need to use and should these items be stored in their own form or on the main order document? Could use some guidance here. Thanks.
The question you have is a little broad but I will make a couple suggestions if I can.
You have the main order doc. Then a repeat control with each item. Filter each item by a uniqueID that allows you to join the main doc to the child docs. Each item should be a separate document. You then need to make the items in the repeat control editable.
There is a lot of things going on here and I think you need to get started somewhere. I think the first step is to do a repeat control with response documents.Xpages, Inherited documents in view panel by using #Unique
i am working in extjs4. I have gridview with cellEditing plugin used.Its working correctly. But after editing foldername its not showing newly updated name of folder on grid. I don't want to refresh store. i just want to show updated name on grid. I have tried as=
getGridPanelStore = getGridPanel.getStore();
folderId = id;
var newtitle = newUpdatedValue;
getRecord = getGridPanelStore.getById(id);
recordToUpdate = getGridPanelStore.indexOf(getRecord ).set('title',newtitle );
But it not setting new updated value on grid. So how to show updated value on grid after editing without loading whole store.
Does this code actually work?
As far as I understand the method indexOf of Ext.data.Store retrieves the index of the record inside the store as an integer thus calling set('title', newTitle) probably will raise an exception of the type Uncaught TypeError: Object n has no method 'set'
Besides that you don't need to load the whole store to get your grid updated, since views are bound to the stores they auto refresh anytime a store field changes, so it should work by changing the title property as follows:
gridStore = gridPanel.getStore();
record = gridStore.getById(recordId);
record.set('title', newTitle);
If value doesn't update that way, you should check if the target column doesn't have a custom renderer associated to it that can be changing the view output for that specific field in any way.