We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GridControl and GridDataControl

Thread ID:

Created:

Updated:

Platform:

Replies:

90587 Oct 8,2009 05:59 PM Oct 22,2009 06:46 AM WPF 15
loading
Tags: GridControl
richard
Asked On October 8, 2009 05:59 PM

I am not sure why there are 2 wpf grid controls in syncfusion products and I don't know their relation ship. Maybe GridDataControl contains GridControl?

Anyway, here are 2 issues I have.

1, I was using GridDataControl because I need to binding the control to ObservableCollection object, then I realized when I set a column GridDataColumnStyle CellType as CheckBox, the user need to double click the cell to get into edit mode and then click to change the checkbox value, that's 3 clicks to change a boolean value.

So I noticed the one using GridControl in your example, user can click once in each cell and edit value immediately, that's exactly what I want, but the problem is, I can not bind my collection object to this GridControl.

Can you help on this please?

2, How do I set the grid column type to be non-editable ComboBox when I need to use data binding? For non-editable I mean either exclusive or autocomplete option.

Thanks.

richard
Replied On October 8, 2009 06:08 PM

3, While using Databinding, as rows growing, how to make the grid automatically scroll to the bottom so the last row is always visible?

Ganesan K [Syncfusion]
Replied On October 9, 2009 03:11 AM

Hi Richard,

Thanks for using Syncfusion products.

GridDataControl uses the GridControl internally. Using GridDataControl you can bind the dataSources directly.

For #1, You need to set the following properties in GridDataControl XAML declaration,

UpdateMode="PropertyChanged"
ActivateCurrentCellBehavior="ClickOnCell"

This will update the changes when clicking the cell as well as update it to the underlying record.

Download the workaround sample in the below location and check it out.
http://www.syncfusion.com/uploads/redirect.aspx?file=sample_442d9b2e.zip&team=development

For #2, You can use the DropDownStyle enumerator for this. It has three values: Editable, Exclusive, AutoComplete. Default value is Editable.

You can use the following code for changing to Exclusive or AutoComplete mode.









For #3, You can use the ScrollToBottom method in GridControlBase for scroll to bottom.

For #2 and #3 you can download the workaround sample from the below location.
http://www.syncfusion.com/uploads/redirect.aspx?file=GDCSample_6f047b27.zip&team=development


Please let me know if you need any more details.

Thanks
Ganesan

richard
Replied On October 9, 2009 10:58 AM

Thanks, that's very fast response. It's almost perfect.

For #3, how do I catch the new row inserted event for the GridDataControl itself?

What I want to do is in the View code:

void dataGrid_NewRowDataInserted(object sender, EventArgs e)
{
foreach (GridControlBase grid in dataGrid.Model.Views)
{
grid.ScrollToBottom();
}
}

So when I want to add new row, I just need to modify the ViewModel.

Ganesan K [Syncfusion]
Replied On October 12, 2009 11:39 AM

Hi Richard,

Thanks for the feedback.

You can listen the Model.View.CollectionChanged event like below

dataGrid.Model.View.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(View_CollectionChanged);


void View_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
dataGrid.Model.View.Refresh();
foreach (GridControlBase grid in dataGrid.Model.Views)
{
grid.ScrollToBottom();
}
}
Please let me know if you need any more details.

Thanks
Ganesan

richard
Replied On October 12, 2009 12:08 PM

Thanks.

I found dataGrid.Model.Views but I can not find dataGrid.Model.View, so the following did not compile:

dataGrid.Model.View.Fresh();

as well as:

dataGrid.Model.View.CollectionChanged

I tried to search GridControl and GridDataControl for reference of the "View" but did not get any hint.

Ganesan K [Syncfusion]
Replied On October 13, 2009 12:57 AM

Hi Richard,

Thanks for the details. dataGrid.Model.View is only avail in our latest build.

We have added new Grouping model in our latest build. Please download the latest build 7.4.0.9 from the below location.

www.syncfusion.com/downloads/development-builds

We also have made a small API changes listing, If you are using anything from this list please refer to the document below,

http://www.syncfusion.com/uploads/redirect.aspx?file=apichanges_3645b05c.doc&team=development

We also fixed some issues regarding in our latest build. If you want this fixed binaries then create the support Incident, we will update you with the Patch file.

Let us know if you need any more details.

Thanks
Ganesan

richard
Replied On October 14, 2009 04:41 PM

Hi, I tried the new version but found too many data binding bugs. While I am waiting for your bug fixing, is there anyway to catch this CollectionChanged event using version 7.3.0.20?

Clay Burch [Syncfusion]
Replied On October 15, 2009 04:33 AM

What is the type of your ItemsSource? Is it an IBindingList object, or a DataTable, or an ObservableCollection, or a CollectionView or something else?

Depending upon what the ItemsSource is, then may be an event on the ItemsSource that allows you to catch changes. This event would not be dependent on any particular Syncfusion version.

Clay Burch [Syncfusion]
Replied On October 15, 2009 05:13 AM

I noticed in your original post, you said you were using a ObservableCollection. Here is a little sample that will always scroll to the bottom after entering a new row from the UI using an observale collection. It uses the grid.Model.RowsInserted event to scroll the last row into view.




WpfApplication26_583fd7b1.zip

richard
Replied On October 19, 2009 04:45 PM

well, that works pretty good, however, I can only get one-way data binding work, I saw the data source got updated when user click and edited the cell value, but when I change the ObservableCollection ViewModel value, the corresponding cell did not get updated. Is there a way I can set the binding mode to be "Two-way"?

My ViewModel is like this:

gridDataControl1.ItemsSource = m_Sales;

public class Sales : ObservableCollection
{
}

public class Record : INotifyPropertyChanged
{
public double Data2
{
get { return m_nData2; }
set {
m_nData2 = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Data2"));
}
}
}

Clay Burch [Syncfusion]
Replied On October 20, 2009 04:11 AM

Make sure these two properties are set on the GridDataControl.

UpdateMode="PropertyChanged" NotifyPropertyChanges="True"

richard
Replied On October 20, 2009 11:21 AM

well, do you have a solution of NotifyPropertyChanges="True" for version 7.3.0.20?

Clay Burch [Syncfusion]
Replied On October 20, 2009 12:25 PM

You can try this. Listen to the CollectionChanged on your ObservableCollection.

m_Sales.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(m_Sales_CollectionChanged);


Then in the handler, refresh the grid.

void Window1_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
foreach (GridControlBase grid in gridDataControl1.Model.Views)
{
grid.InvalidateCells();
}
}


This is not optimal code, but I think will work in 7.3.0.20. Using 7.4 with its new properties would be better.

richard
Replied On October 21, 2009 02:58 PM

This does not work if I change the individual field value, it might only work if I add/delete row data.

And also we are using the MVVD model, we want to seperate the ViewModel from the View, so we want the event to be catched and handled within the View only.

I tried the new version 7.4.0.9 for the 2-way data binding and can not make it working. I sent the incident ticket update 2 days ago, can you please check it out? 61066

Ganesan K [Syncfusion]
Replied On October 22, 2009 06:46 AM

Hi Richard,

We have updated the incident #61066 with the Two way data binding sample. Please check it out.

Thanks
Ganesan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;