Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1155
Filter and Refresh two grids
posted

Background & Expectations: My window has 2 independent grids with two independent data sources. They do have a common field, but this is not Northwind so there is no linking and no internal relationship.

When I double-click on a record in the top grid, I want too filter the view in the bottom grid such that I identify a key value in both and limit as such. Sounds easy until I realized XamDataGrid has no filtering.

Data: As far as my data goes it is very complex for the Infragistic brain. I am using nested lists which are further derived using linq query. I have massaged the data to the most basic level so that the poor datagrid can find it. The ResultsView is assigned to the DataContext and DataSource respectively.

The fun part:

I've got those two grids, one with an anonymous data type which I need to evaluate and convert to some data type. That's all set. I am attempting to use vew.Filter to filter out the bottom records by the current record in the top. Easy enough, but as usual I am having trouble telling XamDataGrid to refresh itself and use the new filter.

Question: How do I use view.refresh or assign the filtered view to the XamDataGrid and then actually make the view display it?

Suggestions Welcome.

I have included the filter portion of my code behind below.

Glenn

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

// Grid double-click event

 

 

private void RegoUnitsList_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs

e)

{

 

 

this

.SynchronizeActiveRecordWithCurrentItem();

}

 

 

// Filter Call

 

 

void

SynchronizeActiveRecordWithCurrentItem()

{

 

_Schedulesgrid =

 

this

.RegoSchedulesList;

_Unitsgrid =

 

this

.RegoUnitsList;

 

 

var view = this

.GetCurrentSchedulesView();

 

 

if (view == null

)

 

 

return

;

 

 

var unitsview = this

.GetCurrentUnitsView();

 

 

if (unitsview == null

)

 

 

return

;

 

 

// Get current Unit Record

 

 

var

currentUnit = unitsview.CurrentItem;

 

 

if (currentUnit == null

)

{

_Unitsgrid.ActiveRecord =

 

null

;

}

 

 

else

{

 

 

var currentUnitRec = _Unitsgrid.GetRecordFromDataItem(currentUnit, false

);

 

 

if (currentUnitRec != null

)

{

currentUnitRec.IsActive =

 

true

;

currentUnitRec.IsSelected =

 

true

;

_Unitsgrid.BringRecordIntoView(currentUnitRec);

count = 0;

 

}

 

// end if

 

view.Filter =

 

delegate(object

item)

{

 

 

List<ASEngine.BusinessObjects.Entities.ASRegoSeqment> MySegments = new List<ASEngine.BusinessObjects.Entities.ASRegoSeqment

>();

 

 

var stronglyTyped = GlennsTypeHack.Cast(item, new { Schedules = default(Nullable<decimal>), UnitScheduleID = default(decimal), Unitschedulelongname = default(string), MinDown = default(string), MaxRun = default(string), MinRun = default(string

), Segments = MySegments });

 

 

if (stronglyTyped.Schedules.ToString() == currentUnitRec.Cells["UnitID"].Value.ToString() && stronglyTyped != null

)

{

 

 

return true

;

}

 

 

else

{

 

 

return false

;

}

 

};

view.Refresh();

 

// ????????????? This does not work

_Schedulesgrid.DataSource = view;

 

// ????????????? This does not work

}

 

}

 

 

ICollectionView

GetCurrentSchedulesView()

{

 

 

return _Schedulesgrid.DataSource == null ? null : CollectionViewSource

.GetDefaultView(_Schedulesgrid.DataSource);

}

 

 

ICollectionView

GetCurrentUnitsView()

{

 

 

return _Unitsgrid.DataSource == null ? null : CollectionViewSource

.GetDefaultView(_Unitsgrid.DataSource);