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

Creating a dynamic EjsGrid, Grid freezes while trying to edit

I created an algorithm that adds/removes items from an EjsGrid based on items from an EjsTreeView checklist. That part works fine and I accomplished it by using @ref on the EjsGrid, however I want one of the columns to be editable. When I try to edit the column in question, the grid freezes. Perhaps I am referencing something wrong and not passing the user's inputted data correctly. I have attached my Visual Studio project. Checkout.razor is the page I am working on.

My grid looks like (as you will see in the zip file):

<EjsGrid DataSource="FinalItems" @ref="grid">
        <GridEditSettings AllowEditing="true"></GridEditSettings>
        <GridColumns>
            <GridColumn AllowEditing="false" Field=@nameof(CheckoutItem.Name) HeaderText="Name" Width="50"></GridColumn>
            <GridColumn Field=@nameof(CheckoutItem.Quantity) HeaderText="Quantity" Width="35" EditType="EditType.NumericEdit"></GridColumn>
        </GridColumns>
    </EjsGrid>

Whenever I attempt to edit Quantity, it freezes.



Attachment: FrontCounter_e266e54a.zip

3 Replies

RS Renjith Singh Rajendran Syncfusion Team November 20, 2019 11:43 AM UTC

Hi Brian, 

Thanks for contacting Syncfusion support. 

The problem occurred because of not enabling the “IsPrimaryKey” property for a unique value column in Grid. To perform editing in Grid, it is a must to define a unique value column as primary key column. 

We suggest you to ensure to provide “IsPrimaryKey” property for any one of the unique value column in Grid.  

 
        <GridColumns> 
            <GridColumn AllowEditing="false" IsPrimaryKey="true" Field=@nameof(CheckoutItem.Name) HeaderText="Name" Width="50"></GridColumn> 
            <GridColumn Field=@nameof(CheckoutItem.Quantity) HeaderText="Quantity" Width="35" EditType="EditType.NumericEdit"></GridColumn> 
        </GridColumns> 


 
Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran.  



BR Brian replied to Renjith Singh Rajendran November 20, 2019 09:43 PM UTC

Hi Brian, 

Thanks for contacting Syncfusion support. 

The problem occurred because of not enabling the “IsPrimaryKey” property for a unique value column in Grid. To perform editing in Grid, it is a must to define a unique value column as primary key column. 

We suggest you to ensure to provide “IsPrimaryKey” property for any one of the unique value column in Grid.  

 
        <GridColumns> 
            <GridColumn AllowEditing="false" IsPrimaryKey="true" Field=@nameof(CheckoutItem.Name) HeaderText="Name" Width="50"></GridColumn> 
            <GridColumn Field=@nameof(CheckoutItem.Quantity) HeaderText="Quantity" Width="35" EditType="EditType.NumericEdit"></GridColumn> 
        </GridColumns> 


 
Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran.  


Thank you this solved my issue.

I am now trying to set it where the minimum value of the Quantity column is 1 and I am also trying to remove decimal input. How can I do this?


RS Renjith Singh Rajendran Syncfusion Team November 21, 2019 11:52 AM UTC

Hi Brian, 

We suggest you to use the “Edit params feature” of Grid. In this, set the “Min” and “Format” properties of EjsNumericTextBox to achieve your requirement. Please refer the documentation link below, 
 
Please use the code below, 

 
<div class="column2"> 
    <EjsGrid DataSource="FinalItems" @ref="grid"> 
        <GridEditSettings AllowEditing="true"></GridEditSettings> 
        <GridColumns> 
            <GridColumn AllowEditing="false" IsPrimaryKey="true" Field=@nameof(CheckoutItem.Name) HeaderText="Name" Width="150"></GridColumn> 
            <GridColumn Field=@nameof(CheckoutItem.Quantity) ... EditType="EditType.NumericEdit" Edit="@QuantityEditParams"></GridColumn> 
        </GridColumns> 
    </EjsGrid> 
</div> 
 
 
@code{ 
    public object QuantityEditParams = new 
    { 
       @@params = new EjsNumericTextBox<int>() { Min = 1, Format = "N0" } 
    }; 
    ... 
} 


Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Loader.
Live Chat Icon For mobile
Up arrow icon