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

Grid Column Edit Type not work

Hello team,

I'm facing a problem with Grid Column Edit Type not working problem. I'm trying to create a grid with variable columns by looping, but when I try to define the edit type of those columns, the editor cannot be generated in grid edit mode. So may I get some help from this powerful team? Many thanks.


My Code:

<SfGrid DataSource="@InterceptConditionRecordsList" Toolbar="@(new List<string>{"Add", "Edit" ,"Delete" ,"Update" ,"Cancel" })"

        @ref="Grid" ID="interceptConditionRecordTable" TValue="ExpandoObject" class="mkDataGrid" >

    <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Normal"></GridEditSettings>

    <GridEvents OnActionBegin="ActionBeginHandler" OnActionComplete="ActionCompleteHandler" OnActionFailure="@ActionFailure" TValue="ExpandoObject"></GridEvents>

    <GridPageSettings PageCount="20" PageSizes="true"></GridPageSettings>

    <GridTemplates>

        <EmptyRecordTemplate>

            <p class="mkDataGridNoRecordMessage">No records to display.</p>

        </EmptyRecordTemplate>

    </GridTemplates>

    <GridColumns>

        <GridColumn Field=@nameof(InterceptConditionRecord.Id) HeaderText="#" IsPrimaryKey="true">

        </GridColumn>

        @if (columns.Count > 0)

        {

            @foreach (var col in columns)

            {

                var definition = col.Value;

                            var fieldTypeValue = definition.InterceptConditionTypeFieldOperator;

                            var fieldTypeString = FieldOperatorList.Where(x => x.InterceptConditionTypeFieldOperator == fieldTypeValue).ToList()[0];

                            var fieldTypeDisplayValue = fieldTypeString.Field?.Key;

                var columnLabel = definition.Field?.Description + " " + fieldTypeDisplayValue;

                var editType = EditType.DefaultEdit;

                if (definition.Field.FieldType == InterceptFieldFieldType.D)

                {

                    editType = EditType.DatePickerEdit;

                }

                else if(definition.Field.FieldType == InterceptFieldFieldType.N)

                {

                    editType = EditType.NumericEdit;

                }

                <GridColumn Field="@col.Key" HeaderText="@columnLabel" ValidationRules="@(new ValidationRules { Required=true})" EditType="@editType" ></GridColumn>

            }

        }

          <GridColumn Field=@nameof(InterceptConditionRecord.ValidFrom) HeaderText="Valid From" ValidationRules="@(new ValidationRules{ Required=true})" Format="d" TextAlign="TextAlign.Right" Type="ColumnType.Date"></GridColumn>

          <GridColumn Field=@nameof(InterceptConditionRecord.ValidTo) HeaderText="Valid To" ValidationRules="@(new ValidationRules{ Required=true})" Format="d" TextAlign="TextAlign.Right" Type="ColumnType.Date"></GridColumn>

    </GridColumns>

</SfGrid>

public partial class InterceptConditionRecord

{

[Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]

public int? Id { get; set; } = default!;


[Newtonsoft.Json.JsonProperty("validFrom", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]

[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]

public System.DateTime ValidFrom { get; set; } = default!;


[Newtonsoft.Json.JsonProperty("validTo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]

[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]

public System.DateTime ValidTo { get; set; } = default!;


[Newtonsoft.Json.JsonProperty("conditionType", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]

public InterceptConditionType? ConditionType { get; set; } = default!;


[Newtonsoft.Json.JsonProperty("fieldValues", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]

public System.Collections.Generic.ICollection? FieldValues { get; set; } = default!;


[Newtonsoft.Json.JsonProperty("revisionId", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]

public System.Guid? RevisionId { get; set; } = default!;


[Newtonsoft.Json.JsonProperty("createdOn", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]

public System.DateTime? CreatedOn { get; set; } = default!;


[Newtonsoft.Json.JsonProperty("createdBy", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]

public string? CreatedBy { get; set; } = default!;


[Newtonsoft.Json.JsonProperty("modifiedOn", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]

public System.DateTime? ModifiedOn { get; set; } = default!;


[Newtonsoft.Json.JsonProperty("modifiedBy", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]

public string? ModifiedBy { get; set; } = default!;


private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary();


[Newtonsoft.Json.JsonExtensionData]

public System.Collections.Generic.IDictionary AdditionalProperties

{

get { return _additionalProperties; }

set { _additionalProperties = value; }

}

}


1 Reply

SP Sarveswaran Palani Syncfusion Team April 20, 2023 04:11 AM UTC

Hi Wai,

Greetings from Syncfusion support.

After reviewing the reported issue, we have created a simple sample to try and reproduce the issue, but we were not able to replicate it from our end. If the issue still persists, we request you to kindly provide us with a simple reproducible sample or try modifying the attached sample to see if the issue can be reproduced there. This will help us in identifying the root cause of the issue and resolving it for you as soon as possible.

Regards,
Sarvesh


Attachment: BlazorApp1_(2)_a9229a77.zip

Loader.
Up arrow icon