Please add tri-state DialogVisible property to GridColumn and GridForeignColumn in SfGrid

Some of my tables have more columns than I want to display in the SfGrid.  But these columns need to be updated when adding/updating a record.  So I have to set the GridEditSettings Mode to EditMode.Dialog and create a Template.  This adds a lot of extra code I have to write.  It would be nice to have a tri-state DialogVisible property on GridColumn and GridForeignColumn that, when null, inherits the Visible property, but if set is applicable on the Dialog edit window only.


3 Replies

RN Rahul Narayanasamy Syncfusion Team November 9, 2021 01:23 PM UTC

Hi Craig, 

Greetings from Syncfusion. 

We have validated your query and we suspect that you want to show some of the fields in Grid edit dialog(without using DialogTemplate) but not while rendering the Grid. If yes, then you can achieve your requirement by using Width property of the column. Here, we have defined Width as 0 for CustomerID and Freight column. Both these columns was not showing while rendering the Grid and it will shown in the Edit Dialog. Find the below code snippets and sample for your reference. 

 
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" Height="315"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" ValidationRules="@(new ValidationRules{ Required=true})" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" ValidationRules="@(new ValidationRules{ Required=true})" Width="0"></GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" EditType="EditType.NumericEdit" Width="0"></GridColumn> 
        <GridColumn Field=@nameof(Order.ShipCountry) HeaderText="Ship Country" EditType="EditType.DropDownEdit" Width="150"></GridColumn> 
    </GridColumns> 
</SfGrid> 
 
@code{ 
    public List<Order> Orders { get; set; } 
 
    . . . 
} 


If it does not meet your requirement, then could you please share more details about your requirement. It will be helpful to validate and provide a better solution. 

Please let us know if you have any concerns. 

Regards, 
Rahul 



CB Craig Boucher November 9, 2021 02:11 PM UTC

This worked perfectly and saved me from having to write a lot of extra code.  Thanks!

Craig



RN Rahul Narayanasamy Syncfusion Team November 10, 2021 04:46 AM UTC

Hi Craig, 
 
Thanks for the update. 
 
We are glad to hear that the provided solution was helpful to achieve your requirement. Please get back to us if you need further assistance. 
 
Regards, 
Rahul 


Loader.
Up arrow icon