Hi, on the attached razor page, i want to be able to be able to Copy the "MyDetails" column to clipboard programmatically. i am using the function below but it copies the whole grid row.
public void OnContextMenuClick(ContextMenuClickEventArgs<Order> args) {
if (args.Item.Id == "copy-column-mydetails")
{ this.DefaultGrid.Copy(false); }
}
please note that i want to have the following settings enabled:
GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Multiple" CheckboxOnly="true" PersistSelection="true"></GridSelectionSettings>
Can you please help?
thanks
Hi Dan,
Greetings from Syncfusion support.
We have analyzed your query and suspect that you want to copy specific column not an entire row. So, we created the sample based on your requirement and enabling selection mode as cell type to copy the specific cell to the clipboard. Kindly refer the attached sample for your reference.
Please get back to us if you have any further queries.
Regards,
Sarveswaran PK
hi,
thanks for the response.
yes, correct-we would like to copy a specific column but programmatically without having to select the specific column first BUT:
we would like to copy without having to select it first. so the copy functions will always copy a specific column.
e.g: this.DefaultGrid.Copy(column-with-name=MyDetails)
the code you sent be below ,we have first to find and click the column we like, and then we must copy.
We would like to do it, without setting enabling selection mode as cell type. is that also possible?
*************
public void Copy()
{
this.DefaultGrid.Copy();
}
Hi DAN,
Thanks for the update.
Query: “we would like to copy without having to select it first. so the copy functions will always copy a specific column.”
We can select the cell programmatically before calling copy method by using SelectCellAsync. Kindly check the attached code snippet for your reference.
|
public async Task Copy() { await DefaultGrid.SelectCellAsync((2,2)); this.DefaultGrid.Copy(); }
|
Query: “We would like to do it, without setting enabling selection mode as cell type. is that also possible?”
No it is not possible to select and copy an cell without enabling selection mode as cell type.
Please let us know if you have any concerns.
Regards,
Monisha
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Is it possible on your code above to programmatically enabling selection mode as cell type
Copy
Then revert grid back to row?
Hi DAN,
Welcome from Syncfusion support.
Query: Programmatically Enabling selection mode as cell type
we can enable selection mode as a cell programmatically by getting an instance from the grid and assigning grid cell selection mode to the grid instance. Kindly refer to the attached code snippet for your reference.
|
public void Copy() { DefaultGrid.SelectionSettings.Mode = Syncfusion.Blazor.Grids.SelectionMode.Cell; this.DefaultGrid.Copy(); } |
Kindly get back to us if you have any further queries.
Regards,
Keerthana.
please see code below. it still does not work when trying to set mode to cell and then copying programmatically.
it copies the whole row.
can you please provide a working code/sample?
if (args.Item.Id == "COPY-BENEFICIARY-LATIN")
{
DoCell();
StateHasChanged();
await this.GridnameVisitActivities.SelectCellAsync( (2, 8));
StateHasChanged();
await this.GridnameVisitActivities.CopyAsync(false);
DoRow();
}
}
public void DoCell()
{
GridnameVisitActivities.SelectionSettings.Mode = Syncfusion.Blazor.Grids.SelectionMode.Cell;
}
public void DoRow()
{
GridnameVisitActivities.SelectionSettings.Mode = Syncfusion.Blazor.Grids.SelectionMode.Row;
}
Hi DAN,
Sorry for the inconvenience.
We are currently Validating the reported query at our end, and we will update the further details within two days(Sept7, 2022). Until then we appreciate your patience.
Regards,
Keerthana.
Hi DAN,
Sorry for the inconvenience caused.
Query: Copying cell when
trying to set the mode to cell and the copying programmatically it copies the whole
row.
We suggest to you refresh the Grid before enabling the selection mode.
Kindly refer to the attached code snippet for your reference.
|
<SfGrid @ref="DefaultGrid" DataSource="@Orders"> <GridSelectionSettings Mode="@rowCellSelect" Type="Syncfusion.Blazor.Grids.SelectionType.Multiple"></GridSelectionSettings> private SfGrid<Order> DefaultGrid; public List<Order> Orders { get; set; } public SelectionMode rowCellSelect=SelectionMode.Both; { DefaultGrid.Refresh(); rowCellSelect = SelectionMode.Row;
}
public void CellSelection() { DefaultGrid.Refresh(); rowCellSelect = SelectionMode.Cell;
} |
Kindly get back to us if you have any further queries.
Regards,
Keerthana.