We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Data manipulation when running add/Update

(Please understand that it has been translated by Google Translate.) I have a question about the grid. If you select values 1 and 2 after clicking add or update, you want to execute a query with the selected value to bring in the value to be inserted in number 3 and insert it automatically. When column number 2 is selected, ValueChange is executed and the value of the query is normally retrieved, but the value cannot be inserted into column number 3. please tell me how to do it (The source is as follows, and the attached screen is the execution screen.) <SfGrid @ref="code_grid" DataSource="@codes" AllowPaging="true" AllowSorting="true" AllowFiltering="false" AllowGrouping="false" ShowColumnChooser="true" Toolbar=@ToolbarItems AllowResizing="true" AllowReordering="true" ShowColumnMenu="true"> <GridPageSettings PageSize="20"></GridPageSettings> <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Dialog" ShowConfirmDialog="true" ShowDeleteConfirmDialog="true"></GridEditSettings> <GridEvents OnActionBegin="ActionBeginHandler_code" OnActionComplete="ActionCompleteHandler_code" TValue="CCodeInfo_sql"></GridEvents> <GridColumns> <GridColumn Field="@nameof(CCodeInfo_sql.CorpNM)" HeaderText="Business Code" EditType="EditType.DropDownEdit" TextAlign="TextAlign.Center" IsPrimaryKey="true" Width="100"> <EditTemplate> <SfDropDownList ID="Corpdw" Placeholder="Select Business Code" TValue="string" TItem="DwCodeval" Enabled="@Enabled_CorpCd" @bind-Value="@((context as CCodeInfo_sql).CorpCd)" DataSource=" @corpList"> <DropDownListFieldSettings Text="Name" Value="Code"></DropDownListFieldSettings> </SfDropDownList> </EditTemplate> </GridColumn> <GridColumn Field="@nameof(CCodeInfo_sql.ManageNM)" HeaderText="Group Code" EditType="EditType.DropDownEdit" TextAlign="TextAlign.Center" IsPrimaryKey="true" Width="100"> <EditTemplate> <SfDropDownList ID="Managedw" Placeholder="Select Group Code" TValue="string" TItem="DwCodeval" Enabled="@Enabled_ManageCd" @bind-Value="@((context as CCodeInfo_sql).ManageCd)" DataSource=" @gCodeList"> <DropDownListFieldSettings Text="Name" Value="Code"></DropDownListFieldSettings> <DropDownListEvents TValue="string" TItem="DwCodeval" ValueChange="(args)=> { ValueChange_code_manage(args, ref context); }"></DropDownListEvents> </SfDropDownList> </EditTemplate> </GridColumn> <GridColumn Field="@nameof(CCodeInfo_sql.CodeCd)" HeaderText="Code" EditType="EditType.DefaultEdit" IsPrimaryKey="true" TextAlign="TextAlign.Center" Width="100" ValidationRules="@(new ValidationRules{Required=true, MaxLength=6})"> <EditTemplate> <SfTextBox ID="CustCodeCd" HtmlAttributes="@(new Dictionary<string, object>() { { "maxlength", 6 } })" Enabled="@Enabled_CodeCd" @bind-Value="@((context as CCodeInfo_sql ).CodeCd)"></SfTextBox> </EditTemplate> </GridColumn> </GridColumns> </SfGrid> @code { public void ValueChange_code_manage(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, DwCodeval> args, ref object context) { // Get the maximum value. DBConnection dbconn = new DBConnection("sortechDB"); var editval = context as CCodeInfo_sql; using (SqlConnection connection = new (dbconn.ConnectionString)) { try { connection.Open(); string queryString = string.Format(@"SELECT FORMAT(ISNULL(MAX(CODECD), 0) + 1, 'D6') AS MAXCODECD FROM [sortech].[dbo].[CodeInfo] WHERE CorpCD = '{0}' AND ManageCD = '{1}'", editval.CorpCd, args.Value); SqlCommand comm = new (queryString, connection); //args.V .ManageCd = comm.ExecuteScalar().ToString(); editval.CodeCd = comm.ExecuteScalar().ToString(); Enabled_CodeCd = false; } catch (SqlException se) { Console. WriteLine(se. ToString()); throw; } finally { connection. Close(); } } } } thanks.
Attachment: 1_27ec280a.zip

1 Reply

NP Naveen Palanivel Syncfusion Team December 21, 2022 02:01 AM UTC

Hi junghwi,

Thanks for contacting Syncfusion support.

We have similar documented this topic under our UG documentation. Please refer the below documentation for more details regarding this requirement. 

Documentation : https://blazor.syncfusion.com/documentation/datagrid/dialog-editing#implement-calculated-column-inside-grid-dialog-editing

Please let us know if you have any concerns.


Naveen Palanivel

Live Chat Icon For mobile
Up arrow icon