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.
Syncfusion Feedback

binding in code behind at run time bi-directionnal SQLlite DB to GDC ?

Thread ID:

Created:

Updated:

Platform:

Replies:

116328 May 14,2014 09:16 PM UTC Jun 12,2014 04:08 AM UTC WPF 7
loading
Tags: GridDataControl
fff
Asked On May 14, 2014 09:16 PM UTC

Hi SF,

Following the SF help from: http://help.syncfusion.com/ug/wpf/grid/default.htm#!documents/databasedata.htm

I have made a code behing connection of a SQLite database with a GridDataControl and binding

        this.GridDataControl_Left.ItemsSource = this.GetDataTable();

and later:

        public DataTable GetDataTable()
        {
            SQLiteConnection engine = new SQLiteConnection(DBConnString );
            engine.Open();
            SQLiteDataAdapter sda = new SQLiteDataAdapter("SELECT * FROM Names", engine);
            DataSet ds = new DataSet();
            sda.Fill(ds);   
            engine.Close();
            return ds.Tables[0];
        }

As my database can be changed on user prefference, I do not know in advance what fields are inside, so I import all the field of one db table, to be binded with the corresponding column in the GDC

The grid reflect corrrectly the database (one direction), that is OK, but when I modify data in the grid, these changes are not updated in database. So not woking Bidirectionnaly now :(
Can you please modify this code or tell me what to add for that ?

Thanks,
Fabrice

(PS: for community, maybe could also be good to later include in the help file and use SQLite and not SQLce as SQLce is deprecated...but that is a different story)


Santhosh
Replied On May 15, 2014 08:27 AM UTC

Hi

You need to update the changes back to database by using the SQLiteDataAdapter. Update Command.
You can add this code by listening the CurrentCellEditingComplete event.

Santyy



fff
Replied On May 16, 2014 03:46 PM UTC

I implemented the CurrentCellEditingComplete event suggested ... but ...

although it works good for string or number cell that you do click "enter" when done

... it works very bad with checkbox cell type

In détails:

if you mouse click the checkbox in the grid, it is visually changed, but the event is not raised until you click another cell or user enter key

Very confusing for user as visually it is changed, so the action is (should!) be finished

... and if you made such checkbox click and then do not click on that control anymore but do something else on the GUI, it is possible that the event is never raised

bug or at least a very unexpected behaviour ? a workaround or to bug report ?

F

PS: changing to another event type (one that is activated before) works better from user point of view, but in fact not, as the logical value of the cell is not updated yet, so incorrect reading by code behind raised by event; so not an option


Jayapradha S [Syncfusion]
Replied On May 19, 2014 02:06 PM UTC

 

Hi Fabrice,

 

Thank you for using Syncfusion Products.

 

We analyzed your query. CurrentCellEditingComplete Event will not be  fired when you change the value of checkbox and it will be fired only after the EndEdit() method.

 

 If you want to access the cell value of check box when you click on a cell, you can use CurrentCellChanging or CurrentCellChanged Event instead CurrentCellEditingComplete.

 

Please let us know if you have any queries.

 

Regards,

Jayapradha S


fff
Replied On May 23, 2014 06:46 PM UTC

I tried the two events suggested.

None work as when they are raised, the value is not changed yet in the grid .... so reading the grid at that moment returns the previous info, not the one changed/updated/added


Any idea ?

F


Jayapradha S [Syncfusion]
Replied On May 28, 2014 04:40 PM UTC

Hi Fabrice,

All the column defined in the GridDataControl will update value based on the UpdateMode property. The default value of the UpdateMode is LostFocus, so all the column update the values to the underlying collection when the current cell is out of focus or moved to another cell. If you set the UpdateMode property as PropertyChanged then only all the column will update the values to the underlying collection when property is changed.

The UpdateMode property also available in column level. If you want to set the value immediately when you interact with the checkbox column, then set the UpdateMode property as PropertyChanged in the checkbox column and also set NotifyPropertyChanges as True in GridDataControl

Please let us know if this solution helps you.

Regards,

Jayapradha


fff
Replied On June 5, 2014 07:58 PM UTC

ok

the two settings, together with CurrentCellChanged event, does the correct behaviour

(not with CurrentCellEditingComplete which was still requiring another cell to be selected)

Thanks,

Fabrice


Jayapradha S [Syncfusion]
Replied On June 12, 2014 04:08 AM UTC

Hi Fabrice,

 

Thanks for your update.

 

CurrentCellEditingComplete event will be triggered only when the cell  changes from edit mode to non-edit mode. But in the case of CurrentCellChanged Event,  event will be triggered when the value is changed in editor which is placed within the cell. This is the actual behavior of those events.

 

If you need any further assistance, feel free to discuss with us. We will always happy to assist you.

 

Regards,

Jayapradha S


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.

Warning Icon 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.Close Icon

;