Event, So that it should be available in sfDataGrid.View|
Query |
Response | |
|
Want to Add Only Blank Row(With AddNewRow Functionality) at Page Load To SfDataGrid With Add New Row Placed at position is at the FixedBottom . |
If you want to add the blank records to the new row, you can use the RowValidating event. In which you need to check whether all the fields have the blank values as given in the below code sample,
Code Sample:
| |
|
Move Cursor To FirstCell In Edit Mode. |
If you want to move the cursor to the first cell on the edit mode, you can use the begin edit event. And change the cursor location to the position as given in the below code sample.
Code Sample:
| |
|
Want to Commit Row at AddNewRowInitiating Event, So that it should be available in sfDataGrid.View |
If you want to add the object to the view using the AddNewRowInitiating event, you can use the View.Records.Add method. It will add the given data object to the records collection.
Code Sample:
| |
|
Want to other columns value based on first or second column |
If you want to modify the other column values based on any other column, you can use the EndEdit event and will change the row data of the AddNewRow based on the given value.
Code Example:
| |
|
Add New Row when Tab key is pressed from the last column Instead Of Enter Key & move the CurrentCell to the first column of the AddNewRow in Edit Mode. |
If you want to move the current cell to the first column on pressing the Tab key, you can use the KeyDown event.
Code Sample:
|
|
sfDataGrid1.CurrentCellActivating += sfDataGrid1_CurrentCellActivating;
sfDataGrid1.View.Records.CollectionChanged += Records_CollectionChanged;
sfDataGrid1.SelectionChanging +=sfDataGrid1_SelectionChanging;
void sfDataGrid1_CurrentCellActivating(object sender, Syncfusion.WinForms.DataGrid.Events.CurrentCellActivatingEventArgs e)
{
if (sfDataGrid1.IsAddNewRowIndex(sfDataGrid1.CurrentCell.RowIndex) && sfDataGrid1.View.IsAddingNew && e.DataRow.RowIndex == sfDataGrid1.GetAddNewRowIndex() + 1)
{
// To cancel the current cell moving to the start row index after adding the new row.
e.Cancel = true;
}
}
void sfDataGrid1_SelectionChanging(object sender, Syncfusion.WinForms.DataGrid.Events.SelectionChangingEventArgs e)
{
if (sfDataGrid1.IsAddNewRowIndex(sfDataGrid1.CurrentCell.RowIndex) && sfDataGrid1.View.IsAddingNew)
{
e.Cancel = true;
}
}
void Records_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
{
// To scroll the grid to the newly added row position.
var scrollValue = this.sfDataGrid1.TableControl.ScrollRows.Distances.GetCumulatedDistanceAt(e.NewStartingIndex);
this.sfDataGrid1.TableControl.ScrollRows.ScrollInView(e.NewStartingIndex);
this.sfDataGrid1.TableControl.VerticalScroll.Value = (int)scrollValue;
}
}
|
|
// To insert the add new row at the top.
sfDataGrid1.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning; |
|
Queries |
Solution |
|
In last post for scrolling down you have mentioned there is some limitation what are those ? |
Please find the limitations of the provided workaround.
|
|
Further after adding scroll down code in sfDataGrid, I am facing issue as mentioned in file attached.
|
We have checked the provided workaround with AddNewRowPosition as FixedBottom as in the attached image. We were unable to reproduce it. Please provide more details about the issue. It will be helpful for us to provide exact solution for it.
|