Changes not detected in Grid when set from other source + searchfield

Hi I have 2 issues in the attached blazor solution.

1. I want to have a distinct list in a dropdown, that, based on selection, also sets the value in the next column, corresponding to values in the data. In my sample I make a subset of data with distinct values and use in the 1. dropdown. The same for the next column, but the grid does not recognise the new values set manually. 
I need some sort of Grid.HasChanges = true; so the "Update" button gets enabled and the BatchSave has both new values in changes. 

2. In the filter textbox I want to give the user the the text "Search.." but when I attach a new textbox to the filter component, it does not correspond with data. What is a workaround to a helpertext in filter?



Attachment: SyncfusionDropdownError_96c098c3.zip

3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team February 12, 2021 06:35 AM UTC

Hi Soren,  
 
Thanks for contacting Syncfusion support.  
 
Query1: “he same for the next column, but the grid does not recognise the new values set manually 
 
We have analyzed your query and we are able to reproduce the reported issue at our end also. We have modified your code example to resolve the reported issue. We have used OnCellSave event of the Grid to update the dropdown column value. Similarly in ValueChange event we have used PreventRender() method of Grid update the toolbar properly.  
 
Refer the below code example.  
 
<GridColumn Field=@nameof(ProductData.Product) HeaderText="Product" EditType="EditType.DropDownEdit"                                TextAlign="TextAlign.Left" Width="@DefaultWidth"                                FilterSettings="@(new FilterSettings{ Operator = Operator.Contains })">                        <HeaderTemplate>                            Product  <span class="e-search-icon e-icons" @onclick="ToggleGridSearchBar"></span>                            <span class="@searchorderIcon" @onclick="@(() => ChangeSortOrder("Grid""Product"))"></span>                        </HeaderTemplate>                        <EditTemplate>                            <SfDropDownList ID="Product" @ref="Dropproduct" Placeholder="Select a Product" TItem="string" TValue="string"                                            @bind-Value="@((context as ProductData).Product)"                                            DataSource="@ProductDistinct" AllowFiltering="true">                                <DropDownListEvents TValue="string" TItem="string" ValueChange="@((args)=>ValueChange(args,context as ProductData))"></DropDownListEvents>                                                          </SfDropDownList>                        </EditTemplate>                    </GridColumn>
 
public void OnCellSave(CellSaveArgs<ProductData> Argsstring grid){    if(Args.ColumnName == "Product")    {        Args.Value = Dropproduct.Value; // update the value for the Product column here.      }}
 
public async Task ValueChange(@Syncfusion.Blazor.DropDowns.ChangeEventArgs<stringstring> args , ProductData rowData){    if(args.Value is not null)    {                    string newSupplier = SupplierDistinct.Where(m => m.Product == args.Value).Select(m => m.Supplier).FirstOrDefault();         double index = await Grid.GetRowIndexByPrimaryKey(rowData.ProductKey);        //update the supplier column here        await Grid.UpdateCell(index, "Supplier", newSupplier);        //        Grid.PreventRender(false);    }}
 
 
Kindly download the modified code example from below  
 
Refer our UG documentation for your reference 
 
 
Query2: “ut when I attach a new textbox to the filter component, it does not correspond with data. 
 
We have analyzed your query and we are able to reproduce the reported behavior at our end. While using EditTemplate, we need to handle the filter operation externally using FilterByColumn method. We have used Input event of TextBox component.  
 
Refer the below code example  
 
<GridColumn Field=@nameof(ProductData.Supplier) HeaderText="Supplier" AllowEditing="false" TextAlign="TextAlign.Left" Width="@DefaultWidth"> 
                        <HeaderTemplate> 
                            Supplier 
                            <span class="e-search-icon e-icons" @onclick="ToggleGridSearchBar"></span> 
                            <span class="@searchorderIcon" @onclick="@(() => ChangeSortOrder("Grid""Supplier"))"></span> 
                        </HeaderTemplate> 
                        <FilterTemplate> 
                            <SfTextBox Placeholder="Search.." Input="OnEnter" /> 
                        </FilterTemplate> 
            </GridColumn> 
public void OnEnter(InputEventArgs args)  {      Grid.FilterByColumn("Supplier","contains",args.Value);  }
 
 
Refer our API documentation for your reference 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Marked as answer

SM Soren M February 12, 2021 02:50 PM UTC

Thank you guys - It works like a charm 


VN Vignesh Natarajan Syncfusion Team February 15, 2021 03:52 AM UTC

Hi Soren,  

Thanks for the update.  

We are glad to hear that you have achieved your requirement using our solution.  

Kinldy get back to us if you have further queries.  

Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon