JibGrid problem

Nov 25, 2010 at 8:10 AM
Edited Nov 25, 2010 at 8:21 AM

Hi,

When the AutoGenerateColumns="True" and filter not match, the datagrid become invisible.

You have to add messagebox and return.

Please Help me.

Coordinator
Dec 4, 2010 at 2:36 AM
Edited Dec 4, 2010 at 2:39 AM

There are several ways to implement the desired functionality.  The easiest way would be to change the  header_PropertyChanged method found on line 210 of the JibGrid.xaml.cs.  The purpose of this event handler is to create the filter predicate each time a the user changes any filter values in the column headers.  We simply need to apply the predicate, and then verify that rows exist if the grid is set to AutoGenerateColumns.  If there are no rows in the ItemSource for the Grid we display the messagebox as requested and since the sender is the last column header which has the offending filter we can simply reset it.  Here is the updated method.  As a side note, you could make each control know what the previous filter was and revert to it, but that is a more envasive change.

 

private void header_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            PagedCollectionView view = this.ItemsSource as PagedCollectionView;
            Predicate<object> predicate = null;
            foreach (var filter in FilterHeaders)
                if (filter.HasPredicate)
                    if (predicate == null)
                        predicate = filter.GeneratePredicate();
                    else
                        predicate = predicate.And(filter.GeneratePredicate());
            view.Filter = predicate;
         

            //Here is the change!

            if ( this.AutoGenerateColumns ==true && view.ItemCount == 0)
            {
                MessageBox.Show("You have filterd out all the columns.  The filter has been removed.");
                ColumnFilterControl header = sender as ColumnFilterControl;
                if (header != null)
                    header.ResetFilterValues(CreateFilterColumnInfo(header.Column));
            }
        }

Feb 10, 2011 at 10:17 AM
Edited Feb 10, 2011 at 10:18 AM

hi

how to achieve AddNewRow Method?(add a new row)

please help me.

Jan 19, 2012 at 9:51 AM
Edited Jan 19, 2012 at 10:08 AM

hi,

i use this datagrid control on sharepoint 2010 silverlight project i have problem that when there is no

items returned from filter the messageBox appeare to user but after he clicking on it ,he see the latest filter he made and not all data can be filtered

 

so......

can u help me

Mar 30, 2012 at 12:19 PM

Hi emyabdo,

You can use the following,

if (this.AutoGenerateColumns == true && view.ItemCount == 0)
{

       MessageBox.Show("You have filterd out all the columns.  The filter has been removed.");

        foreach (var filter in FilterHeaders)
        {
                 if (filter.HasPredicate)                           
                          filter.ResetFilterValues(filter.FilterColumnInfo);
        }
}