I have a table "tbl_credit_memos" to store credit memo detial. The credit_memos table has among other, a field for 'CustomerNo' and a field for "InvoiceNo".
tbl_credit_memos is displayed in a wingrid call ug_Main.
I have a dropdown (udd_CustomerNo) that is bound to the CustomerNo column in ug_Main(both the value and display properties are "CustomerNo"). udd_CusomterNo is populated by information from a table called tbl_Customers.
I also have a dropdown (udd_InvoiceNo) that is bound to the InvoiceNo column in ug_Main(both the value and display properties are "InvoiceNo"). udd_InvoiceNo is populated by information from a table called tbl_Invoices.
The above works fine, however, I need the invoice dropdown(udd_invoiceNo) to only display those invoices that are for the CustomerNo selected in the udd_CustomerNo drop down. Any help would be greatly appreciated.
I am using VS2010(visual basic), windows forms, and 10.3 Win CLR2x. Thanks.
Creating a dropdown list in a grid cell whose list values are dependent on another cell - Windows Forms - Infragistics Community
Mike - Thank you for the link. Looks fairly straight forward but I cannot quite figure out the correct vb 2010/10.3 Win form syntax for the following:
UltraGridBand rootBand = this.citiesDropDown.DisplayLayout.Bands[0];
rootBand.ColumnFilters.ClearAllFilters();
rootBand.ColumnFilters["StateID"].FilterConditions.Add
if you could point me in the right direction i would appreciate it(if this was a really stupid question, I apologize in advance :)
Thanks
Hey Mike! thanks for responding. well, the grid is loaded by this time. i see the dropdowns and am able to select a value in PORTFOLIO_CODE. It's the rootBand.ColumnFilters["TRADING_STRATEGY"] line. i don't have a "TRADING_STRATEGY" column filter. no idea what even is.
i'm saying grid_AfterCellUpdate...
if columnkey=PORTFOLIO_CODE
{
the only columns i see in rootBand.ColumnFilters are all fields from table A (which is the PORTFOLIO, i'm not trying to filter that.) i'm trying to filter table B.PORTFOLIO_CODE.
}
table A( bound to portfolio_dropdown)
PORTFOLIO, PORTFOLIO_CODE
table B( bound to strategy_dropdown)
PORFOLIO_CODE, TRADING_STRATEGY
am i totally off the mark here?
The idea here is to filter the DROPDOWN in the second column. So "TRADING_STRATEGY" is a column in the dropdown. My guess is that rootBand is your grid's root band and not the root band of the dropdown and that's why it's blowing up, because there is no "TRADING_STRATEGY" column in the grid.
OK. that's what it was. i should have been using the rootBand of the strategy_combo
UltraGridBand rootBand = STRATEGY_dropdown.DisplayLayout.Bands[0];
rootBand.ColumnFilters["PORTFOLIO_CODE"].FilterConditions.Add(FilterComparisionOperator.Equals, e.Cell.Row.Cells["PORTFOLIO_CODE"].Value);
thanks again Mike
Al
Hey Mike, have another Q. lets say when i select a portfolio in one dropdown, if the strategy dropdown has count (for that portfolio) >0, default the strategy to the first one in the strategy dropdown. can it work like that?
thanks
found a solution..loop. :/
private void gridData_AfterCellUpdate(object sender, CellEventArgs e) { if (e.Cell.Column.Key == "PORTFOLIO") { UltraGridBand brokerBandToFilter = this._cbbrok.DisplayLayout.Bands[0]; brokerBandToFilter.ColumnFilters.ClearAllFilters(); brokerBandToFilter.ColumnFilters["TRADE_TYPE"].FilterConditions.Add(FilterComparisionOperator.Equals, e.Cell.Row.Cells["TRADE_TYPE"].Value); brokerBandToFilter.ColumnFilters["PORTFOLIO"].FilterConditions.Add(FilterComparisionOperator.Equals, e.Cell.Row.Cells["PORTFOLIO"].Value); if (_cbbrok.Rows.VisibleRowCount > 0) //<===== { foreach (var row in _cbbrok.Rows) //<===== { if (!row.IsFilteredOut) //<===== { e.Cell.Row.Cells["CLEARING_BROKER"].Value = row.Cells["COUNTERPARTY_ID"].Value; //<===== break; } } } } }
Yeah that makes sense.
thanks Mike
Hi Al,
The combo doesn't have any built-in functionality to remove duplicates from the list. You would have to do that on the data source, or else filter out the duplicates yourself, which probably wouldn't be very efficient.
thanks Mike. that did work. i will mark as accepted answer.
But i have another question regarding the rows in _cbbrok. is there way to display only unique values?
i've bound it do a datasource that is distinct by another field in the datatable. i'm binding this cbo to the same data but displaying a different field. (one that happens to be repeating). can i just show distinct?
lmk if i'm not making sense.
You could simplify this a little, by using
foreach (var row in _cbbrok.Rows.GetFilteredInNonGroupByRows())
This will loop through only the visible rows, so you do not need the IsFilteredOutCheck. This would also account for rows that you hid explicitly by setting the Hidden property, in addition to those rows that are filtered out.