As far as I understand, ProductName column is shown via a display methods. At least for my implementation here and this method resides in InventSum table:
display public ItemNameDisplay itemName()
{
// Fields might not have been selected on the specified buffers, or might have been updated since selection
this.checkInvalidFieldAccess(false);
if (this.InventDimId)
{
return this.inventTable().itemName(InventDim::find(this.InventDimId));
}
return this.inventTable().itemName();
}
When I hit Ctrl + G and try to filter the data, this option is disabled for the above column and I think this happens due to that display method. Is there any way I could achieve this functionality?
Should I try ( at right click ) to add another MenuItem there and do the filtering with the help of a new dialog ( where i will write down the item name),somehow followed by a refresh on the form?
Update 1:
I've found and edited this approach for my special case:
public void context()
{
InventTable inventTable;
int selectedMenu;
real test;
formrun fr;
Args ag;
Itemname strtext;
querybuilddataSource qb1;
queryrun qr;
query q;
PopupMenu menu = new PopupMenu(element.hWnd());
int a = menu.insertItem('Find');
int c = menu.insertItem('Remove Filter');
selectedMenu = menu.draw();
switch (selectedMenu)
{
case -1:
break;
case a:
ag = new args('SysformSearch');
fr = new formrun(ag);
fr.run();
fr.wait();
strtext = fr.design().controlName('FindEdit').valueStr();
if(strtext)
{
select ItemId from inventTable
where inventTable.NameAlias == strtext;
InventSum_DS.filter(FieldNum(InventSum,ItemId),Sysquery::value(inventTable.ItemId));
}
break;
case c :
InventSum_DS.removeFilter();
break;
Default:
break;
}
}
Still I think is not the correct way to just display a new PopupMenu. I would like to hook to the usual menu and add the new Find and Remove Filter right there. And .. remove filter takes a while, I should signal this somehow so the user don't panic.
I've found this article:
Join ItemName from (EcoResProductTranslation )
Basically, we create a query based on InventTable, EcoResProduct and EcoResProductTranslation in order to get the name of the product starting from the Product field in the InventTable.
A new relation is added on InventSum:
On InventOnHandItem > DataSources > InventSum > Methods > executeQuery I've added the new ds:
element.inventDimSetupObject().modifyQuery(inventSum_DS,inventDim_DS, InventLookupView_ds);
And in the class :
InventDimCtrl_Frm_OnHand > modifyQuery, I've added this parameter:
FormDataSource _inventLookup = null
so now i have this:
public void modifyQuery(
FormDataSource _inventSum_DS,
FormDataSource _inventDim_DS,
FormDataSource _inventLookup = null
)
A query build data source instance :
QueryBuildDataSource qbsInventLookup;
And this section of code:
if(_inventLookup)
{
qbsInventLookup = query.dataSourceName(_inventLookup.name());
//filter current company language
//qbr = SysQuery::findOrCreateRange(qbsInventLookup, fieldnum(InventLookupView, LanguageId));
//qbr.value(queryValue(CompanyInfo::languageId()));
qbsInventLookup.addGroupByField(fieldNum(InventLookupView, Name));
//qbsInventLookup.addGroupByField(fieldNum(InventLookupView,NameAlias));
}
The newly created view is added as a data source in the InventSum :
And drag the Name field from this data source to the grid. It worked just fine for me.