Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
896
Customised XamGrid having trouble while adding new row in V 9.1 (working ok in v 8.2)
posted

Hi

I have customised the XamDataGrid to add new row on click of a button outside the grid.

For this purpose i bind an observable collection to the grid.

The code in custom XamDataGrid to add a new row is as below

 

Public Sub AddRow(ByVal tempEntity As Object)

Try

Dim dataSource As IList = Me

.DataSource

dataSource.Add(tempEntity)

Me.DataSource = dataSource

Me.ExecuteCommand(DataPresenterCommands.RecordLastOverall)

intNewRowCounter = intNewRowCounter + 1

Me.ActiveRecord = Me

.Records(dataSource.Count - 1)

lstSelectedItems = New List(Of Object)

lstSelectedItems.Add(TryCast(Me.ActiveRecord, DataRecord).DataItem)

intPrevIndex = TryCast(MeEnableCellEditing().ActiveRecord, DataRecord).DataItemIndex

Me.FieldSettings.LabelClickAction = LabelClickAction.Nothing

RaiseEvent OnAdd(Me)

Catch ex As Exception

Throw ex

End Try

 

End Sub

 

 

 

Here the tempEntity is passed to the grid and is added to the Datasorce of the grid.

 

in this line of code

Me.ActiveRecord = Me.Records(dataSource.Count - 1)

i am setting the newly added row as the active one

This is working fine in the prototype i developed using trial cersion 8.2

but recently i bought the full version V 9.1 and this code is throwing error at the line above

 

The reason being Me.Records is not updated with the new count while the datasource is.

The exception was Index out of bounds.

The only thing not common to the development environment was the version.

could this be a bug.

Expecting a reply

Thanks in advance

Abhi