The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Working with Infragistics Grid

Last post 07-06-2007, 5:38 AM by strattonn. 3 replies.
Sort Posts: Previous Next
  •  06-28-2007, 9:06 AM 3429

    Working with Infragistics Grid

    BTW I love working with EntitySpaces! Coding just becomes so easy.

    I am working with the Infragistics grid and thought I would post my code for creating an updateable grid. It is pretty simple and does not require a save button on the form.
    Comments are welcome.

    Code:
            //The child grid ultraGridUserCustLocations is bound to userCollectionBindingSource
            //userCollectionBindingSource is bound to userCustomerLocationsCollection1
            //The parent grid is ultraGridUsers
    private void userCollectionBindingSource_CurrentChanged(object sender, EventArgs e) { //The parent record has changed. Load the new child details User usr = new User(); usr = (User)userCollectionBindingSource.Current; userCustomerLocationsCollection1 = usr.UserCustomerLocationsCollectionByUserId; bindingSourceUserCustLocations.DataSource = userCustomerLocationsCollection1; } private void ultraGridUserCustLocations_AfterRowsDeleted(object sender, EventArgs e) { //Update the collection to remove the deleted entry if (userCustomerLocationsCollection1.IsDirty) { userCustomerLocationsCollection1.Save(); } } private void CheckUserCustLocationDataRow() { //Check if this is a new row the user is adding if (ultraGridUserCustLocations.ActiveRow != null && ultraGridUserCustLocations.ActiveRow.IsAddRow) { if (!ultraGridUserCustLocations.ActiveRow.IsUnmodifiedTemplateAddRow) { //Set the primary key that is not shown in this detail grid ultraGridUserCustLocations.ActiveRow.Cells["UserId"].Value = ultraGridUsers.ActiveRow.Cells["UserId"].Value; } else { //User entered and exited the new record without changing anything. ultraGridUserCustLocations.ActiveRow.CancelUpdate(); } } //If this row has been changed persist the changes to the database if (ultraGridUserCustLocations.ActiveRow != null && (ultraGridUserCustLocations.ActiveRow.DataChanged || ultraGridUserCustLocations.ActiveRow.IsDeleted)) { ultraGridUserCustLocations.UpdateData(); if (userCustomerLocationsCollection1.IsDirty) { userCustomerLocationsCollection1.Save(); } } }
  •  06-28-2007, 11:48 AM 3433 in reply to 3429

    Re: Working with Infragistics Grid

    Thx for the compliment, and the awesome post. When it comes to 3rd-party controls, this sort of contribution is invaluable.
    David Neal Parsons
    www.entityspaces.net
  •  07-05-2007, 4:58 PM 3613 in reply to 3429

    Re: Working with Infragistics Grid

    A full working example would be better. Like a complete solution zip file for just one grid, not parent and child grids, would be fantastic. There is not enough information in this fragment and I wasn't able to do anything with this.

    Who calls CheckUserCustLocationDataRow() and why? This is not shown.

     

     

  •  07-06-2007, 5:38 AM 3638 in reply to 3613

    Re: Working with Infragistics Grid

    I am working on this. I am learning the specifics of ES and Infragistics. For instance ES does not allow the updating of primary key fields. This requires specific handling. I will post once I have it complete.

    For reference I call CheckUserCustLocationDataRow()  here.

    Code:
            private void ultraGridUserCustLocations_BeforeRowDeactivate(object sender, System.ComponentModel.CancelEventArgs e)
            {
                if (!CheckUserCustLocationDataRow())
                {
                    e.Cancel = true;
                }
            }
            private void ultraGridUserCustLocations_Leave(object sender, EventArgs e)
            {
                //Currently testing this to see if this works the way I need it to.
    
                //Clicking on another grid does not deactivate the row, but I need to check
                //the row before I go to another grid, so deactivate the row from here.
                ultraGridUserCustLocations.ActiveRow.Activated = false;
            }
            private void frmUsers_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (!CheckUserCustLocationDataRow())
                {
                    e.Cancel = true;
                }
            }
    
View as RSS news feed in XML