Passing the value of grid column to modal popup

  1. When I select records the click the Charges button. It will display the value of CheckDate, ChequeNo, CheckAmount and Remarks.Screenshot (547).png

2 Replies

BC Belle Cruz January 26, 2022 06:15 AM UTC

2. When the modal popup is displayed then it will display also the value of the selected records. Screenshot (549).png



RN Rahul Narayanasamy Syncfusion Team January 27, 2022 01:49 PM UTC

Hi Belle, 

Greetings from Syncfusion. 

Query: Passing the value of grid column to modal popup 

You want to show the selected records details in model dialog when clicking toolbar button(Charges). You can achieve your requirement by using Grid events(RowSelected, OnToolbarClick). Here, we have shown the selected records in model dialog. Find the below code snippets and sample for your reference. 

 
. . . 
 
 
<SfDialog Width="450px" ShowCloseIcon="true" IsModal="true" @bind-Visible="@IsChargesVisible"> 
    <DialogTemplates> 
        <Header> Dialog </Header> 
        <Content> 
            <div> 
                <div class="form-row"> 
                    <div class="form-group col-md-6"> 
                        <label for="orderedit">OrderID</label> 
                        <input class="form-control" @bind="@(SelectedProduct.OrderID)" type="number" disabled /> 
                    </div> 
                    <div class="form-group col-md-6"> 
                        <label for="customeredit">CustomerID</label> 
                        <SfTextBox ID="CustomerID" @bind-Value="@(SelectedProduct.CustomerID)"></SfTextBox> 
                    </div> 
                </div> 
 
                <div class="form-row"> 
                    <div class="form-group col-md-6"> 
                        <label for="freightedit">Frieght</label> 
                        <SfNumericTextBox ID="Freight" TValue="double?" @bind-Value="@SelectedProduct.Freight"></SfNumericTextBox> 
                    </div> 
                    <div> 
                        <label class="e-float-text e-label-top">Order Date</label> 
                        <SfDatePicker ID="OrderDate" @bind-Value="@SelectedProduct.OrderDate"></SfDatePicker> 
                    </div> 
                </div> 
 
                <div class="form-row"> 
                    <div class="form-group col-md-6"> 
                        <label for="countryedit">ShipCountry</label> 
                        <SfDropDownList ID="ShipCountry" @bind-Value="@SelectedProduct.ShipCountry" TItem="Country" TValue="string" DataSource="@Dropdown"> 
                            <DropDownListFieldSettings Value="ShipCountry" Text="ShipCountry"></DropDownListFieldSettings> 
                        </SfDropDownList> 
                    </div> 
                </div> 
                <div class="form-row"> 
                    <div class="form-group col-md-6"> 
                        <label>Please enter a reason:</label> 
                        <SfTextBox @ref="TextBoxRef" Placeholder='Reason'></SfTextBox> 
                    </div> 
                </div> 
            </div> 
        </Content> 
    </DialogTemplates> 
    <DialogButtons> 
        <DialogButton Content="OK" IsPrimary="true" OnClick="@OKCloseDialogCharges" /> 
        <DialogButton Content="Cancel" OnClick="@CancelCloseDialogCharges" /> 
    </DialogButtons> 
</SfDialog> 
 
 
@code{ 
    SfGrid<Order> Grid; 
    SfTextBox TextBoxRef; 
    private List<Object> Toolbaritems = new List<Object>() { "Add", "Edit", "Delete", "Update", "Cancel", 
        new ItemModel() { Text = "Archive", TooltipText = "Archive", PrefixIcon = "e-click", Id = "Click" }, 
    new ItemModel() { Text = "Charges", TooltipText = "Charges", PrefixIcon = "e-click", Id = "Charges" }}; 
    . ..  
    public void RowSelectHandler(RowSelectEventArgs<Order> args) 
    { 
        SelectedProduct = args.Data;    //get selected record data 
        selectedIndex = args.RowIndex;  //get selected row index 
    } 
    public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args) 
    { 
        . . . 
        if (args.Item.Id == "Charges") 
        { 
            var selected = await Grid.GetSelectedRecordsAsync(); 
            if (selected.Count > 0)    //check whether anyone of the reocrds are selected or not 
            { 
                this.IsChargesVisible = true;    //shown dialog 
            } 
        } 
    } 
    private bool IsVisible { get; set; } = false; 
    private bool IsChargesVisible { get; set; } = false; 
 
    . .  
    private async Task OKCloseDialogCharges() 
    { 
        SelectedProduct.Remarks = TextBoxRef.Value; 
        await this.Grid.UpdateRowAsync(selectedIndex, SelectedProduct);  // update the row using method 
        this.IsChargesVisible = false; 
    } 
    private async Task CancelCloseDialogCharges() 
    { 
        this.IsChargesVisible = false; 
    } 
} 
 
<style> 
    .form-group.col-md-6 { 
        width: 200px; 
    } 
 
    label.e-float-text { 
        position: relative; 
        padding-left: 0; 
        top: 10%; 
    } 
</style> 


Please let us know if you have any concerns. 

Regards, 
Rahul  
 


Loader.
Up arrow icon