Showing data when after BeginEdit()

Not Answered This post has 0 verified answers | 1 Reply | 2 Followers Thread's RSS feed.

Ajay_Sungard
Points 225
Replied On: Wed, Jan 21 2009 8:33 AM Reply

Hello,

I am working on an application where I need to show up the data in grid before EndEdit() is called on DataRow. Is there a way through which I can showup that in datagrid. Below is my code...

========================================

 

 

 

 

 

 

 

 

 

 

public

 

 

partial class Window1 :

Window

{

DataTable dt = new DataTable();

 

 

XPSXamDataGrid

mainGrid;

public Window1()

{

InitializeComponent();

CreateData();

this.Loaded += new RoutedEventHandler(Window1_Loaded);

}

void Window1_Loaded(object sender, RoutedEventArgs e)

{

mainGrid =
new XPSXamDataGrid();

mainGrid.Theme =

 

"Onyx"

;mainGrid.GroupByArea.Visibility =

Visibility.Collapsed;

mainGrid.DataSource = dt.DefaultView;

 

FieldLayout fLayout = new FieldLayout();fLayout.Settings.SelectionTypeRecord = Infragistics.Windows.Controls.SelectionType.Single;

mainGrid.FieldLayouts.Add(fLayout);

mainGrid.FieldSettings.LabelClickAction =

 

LabelClickAction

.Nothing;mainGrid.FieldSettings.CellClickAction =

CellClickAction.SelectRecord;

 

mainGrid.EditModeEnded +=
new EventHandler<Infragistics.Windows.DataPresenter.Events.EditModeEndedEventArgs>(mainGrid_EditModeEnded);

 

 

 

// Add it to main border

Border mainBorder = temp.Children[0] as Border;

mainBorder.Child = mainGrid;

}

void mainGrid_EditModeEnded(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndedEventArgs e)

{

e.Cell.Record.Update();

dt.Rows[e.Cell.Record.Index].BeginEdit();

dt.Rows[e.Cell.Record.Index][
"City"] = dt.Rows[e.Cell.Record.Index]["Zip"] + " After Field";

}

public void CreateData()

{

dt.Columns.Add(
new DataColumn("Address1", typeof(string)));

dt.Columns.Add(

 

new DataColumn("Address2", typeof(string

)));dt.Columns.Add(

new DataColumn("Address3", typeof(string)));

dt.Columns.Add(

 

new DataColumn("Zip", typeof(string

)));dt.Columns.Add(

new DataColumn("City", typeof(string)));
for (int i = 0; i < 10; i++)

{

 

 

DataRow

dr = dt.NewRow();dr[

"Address1"] = "Address1_" + i.ToString();

dr[

 

"Address2"] = "Address2_"

+ i.ToString();dr[

"Address3"] = "Address3_" + i.ToString();

dr[

 

"Zip"] = "Zip_"

+ i.ToString();dr[

"City"] = "City_" + i.ToString();

dt.Rows.Add(dr);

}

}

========================================

The changes done in EditModeEnded is not showing up in grid. When I call EndEdit() or datarow, I can see the values being showing up in grid. Is there a way through which the DataRow values can be shown up without the call of EndEdit(). I have some specific reason for not calling EndEdit on datarow.

Thanks,

 

 

 

  • Post Points: 20

All Replies

Replied On: Wed, Mar 18 2009 3:56 AM Reply

Hello,

I suggest you not using the e.Cell.Record.Update() method . Also you can try this in the mainGrid_EditModeStarted event handler:

private

 

void xamDataGrid1_EditModeStarted(object sender, EditModeStartedEventArgs e)

{

e.Editor.ValueChanged +=

new RoutedPropertyChangedEventHandler<object>(Editor_ValueChanged);

}

void

 

Editor_ValueChanged (object sender, RoutedPropertyChangedEventArgs<object> e)

{

//update the datasource

}

This way whenever you changed the value in the editor you can change the DataSource before the EndEdit() method is called.Hope this helps.

 

 

Best regards

Vlad

Sincerely,
Vlad
Developer Support Engineer, MCTS
Infragistics Inc.
www.infragistics.com/support

  • Post Points: 5
Page 1 of 1 (2 items) | RSS