Vaadin 7 - retrieve Beanitem from Grid Editor CommitEvent - grid

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.

Related

Display label based on, field on one data-source (singular) being within another data-source fields many

I am still learning, and looking for help on how to display a label based on one data-sources field value, being within another data-sources field value list.
I have one calculated table, displaying rows of documents within a folder, and wish to use a field representing the document number in that data-source, so that if it's ANYWHERE within another tables field it displays my label.
I've been trying to use projection as I think this is how to achieve it.
I can get it working based on both the current #datasouce.item.fieldnames but need it to base the calculation on all possible numbers in that tables field (Image below should make it easier to understand).
I expect that it has something to do with projections, but can't find anything within the learning templates or anywhere else to resolve the issue.
I think the following should work for you. For the 'Reserved' label have the following binding for the text property:
(#datasources.project_quotes.items..quotenumber).indexOf(#widget.datasource.item.Qnumber) !== -1 ? 'Reserved' : ''
I would suggest alternatively just to include a field in your calculated datasource and making the determination in your server script.

IN_VND_ITM_XLS Excel to CI - New field added to CI does not get inserted

I have added a new field into the IN_VND_ITM_XLS component interface, (BU_PRICE_STATUS), which is in a SQL View already part of the delivered template, ITM_VND_UMP_CVW. I modified the view (Record definition) in App Designer to pull in the BU_PRICE_STATUS field and then modified the component interface and added this field.
When I regenerate the template in Excel, it populates the additional field fine, I select it as an input cell (along with the others I originally had) and I submit the data and return back the green OK status.
When I look online in PeopleSoft I see that the vendor data was created for the item, however the BU_PRICE_STATUS field is populated with a different value than what I specified on the upload. The default value listed on the field definition in app designer was what was populated, instead of the value I had entered for the upload.
Is there something else I did to modify for this to work? I know that when you run the Item Loader process, it uses a Message definition (IN_MST_ITM_XLS) so I wasn't sure if the message needed to be updated to? Thanks in advance.
2/27 EDIT:
I've found that the Component (for this component interface) - IN_MST_ITM_XLS uses a function called PRCSITEM within a Function library record - FUNCLIB_INEIP and this populates data in a staging table called PS_ITM_VND_UMPR_EC. I see that this table does not contain the field BU_PRICE_STATUS (which I didn't believe it would) so I'm thinking if the code/table can be updated to capture this field it would work. Hoping someone can suggest if I'm in the right area and what would need to be changed.

Execute Ribbon Command Button Function in CRM 2013/2015 for all records in current view

For Microsoft CRM 2013 is there any way to get the current view ID? It seems from my research the solution in CRM 2011 no longer works in CRM 2013. (or 2015)
The idea is execute a JavaScript code from a custom command bar ribbon button that executes over all records in the current homepage grid of an entity (or even a sub-grid).
Either by grabbing the current view ID or the FetchXML of a grid would work.
Alternatively, a custom entity that has a lookup to all views for a specific (With its own lookup to a custom entity that populates a view name when it is created/updated/deleted on a specific entity via a plugin) Which I haven't found a way possible yet.
With Ribbon buttons you can pass the IDs from the grid using CrmParameter: https://msdn.microsoft.com/en-us/library/gg309332.aspx
SelectedControlSelectedItemIds - A string array of GUIDs for all selected items in a grid.
SelectedControlAllItemIds - A string array providing the GUIDs for all items displayed in a grid.
SelectedControlUnselectedItemIds - A string array of GUIDs for all unselected items in a grid.
You should be able to get the id of the current view through this line of code:
var currentViewId = $('.ms-crm-View-Name:visible[currentview]').attr('currentview')
But be warned, it is a hack, and may break from one version/update to the next

Populate a value in combobox dynamicly

I have a form where user picks a Item# and gets info for the selected Item. This form got enhanced by adding another filter, using a combobox control, to select a 'warehouse'.
I could use a lookup for the warehouse(the list is huge) to chosse a 'warehouse' but what am trying to do to query warehouse on Item# value and populate into combobox.
Tried to attached a screen shot, unfotunately, the system doesn't let me do it. If I need to put more details, please let me know.
Is it doable?
I would suggest you to do this with a temporary table. Create one in AOT, and declare it as global variable in your form.
When Item (datasource field or design control, choose what's more accurate for you) is modified, just delete table content, and fill it at your needs.
In the control lookup method, call temporary table lookup method, i.e. "static void lookup(TMPTable _tmpTable)". Do a SysTableLookup, with a standard query over TMPtable, but it's important to use QueryBuildDataSource.setCursor(_tmpTable) (I don't remember now where was method setCursor() in Query or QueryRun, search for it a bit).

SmartGWT ListGrid FilterEditor getValue

I have a little appliation that shows MySQL data in web browser ListGrid. It has 14 columns.
I would like to upgrade it so the user could add query parameters.
For this job the best I could imagine is the grid.setShowFilterEditor() that put text boxes above the column headers and will live together with the column header when moved or resized.
I planned to use the filter button FilterEditorSubmitHandler() to get the filter values and run the query.
Unfortunately, I can not find any solution to get the text from a certain filter box eg. the value that was written by the user into the box above Column_#1. Is there any way to do that or this FilterEditor grown together with the DataSources object, and not available for any other data binding?
Something like this, but without using DataSource:
http://www.smartclient.com/smartgwt/showcase/#grid_sortfilter_disable_filter
As per my knowledge, filter editor works on com.smartgwt.client.data.DataSource only.
If you want to have filterEditor in ListGrid, you have to use DataSource or go for some custom implementation.

Resources