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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Update grid record

Thread ID:

Created:

Updated:

Platform:

Replies:

128382 Jan 18,2017 04:49 AM UTC Jan 23,2017 04:28 AM UTC ASP.NET Web Forms 5
loading
Tags: Grid
Pratheep
Asked On January 18, 2017 04:49 AM UTC

Hi

It's possible When  add new record check that product code already exists or not in the grid..if exist that product code than update the records (example update Qty) ..if not exists than add new records.

Thanks
Pratheep

Attachment: WebApplication1_bf16754b.rar

Venkatesh Ayothi Raman [Syncfusion]
Replied On January 19, 2017 12:58 PM UTC

Hi Pratheep, 
Thanks for contacting Syncfusion support. 
We were analyzed your project that you have shared for us and we have achieved your requirement using EndAdd client side event in Grid. In this event, we can make sure the if the added product code is unique or same, if the product code is same then added function will be performing otherwise update action will perform in Grid.  
We have also modified your sample for your convenience. Please refer to the sample and cod example, 
Code example
@Grid 
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
            <ContentTemplate> 
 
                <ej:Grid ID="ProductGrid" ClientIDMode="Static" runat="server" AllowPaging="True" AllowFiltering="false" OnServerEditRow="EditEvents_ServerEditRow" 
                    OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow"> 
                  
                    <ClientSideEvents ActionComplete="complete" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit" /> 
                    <Columns> 
                        . . . 
                    </Columns> 
                    <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True" EditMode="DialogTemplate" DialogEditorTemplateID="#protemplate"></EditSettings> 
                    <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings> 
                </ej:Grid>            
 
@EndADD event 
function endAdd(args) { 
            var len = this.model.dataSource.length; 
            for (var i = 0; i < len; i++) { 
                if (i != 0 && args.data.Productcode === this.model.dataSource[i].Productcode) { 
                    this.model.dataSource.splice(0, 1); 
                    this.model.dataSource[i-1].Productname = args.data.Productname; 
                    this.model.dataSource[i-1].qty = args.data.qty; 
                    this.refreshContent(); 
                    return false; 
                } 
            } 
            
        } 

Regards, 
Venkatesh Ayothiraman. 


Pratheep
Replied On January 20, 2017 02:52 AM UTC

Hi Venkatesh Ayothiraman

Thank you for your replay.  already exists product code (10003)  qty is 3  in the grid . than  if i enter same product code (10003)  2  qty ... Can I update qty 5 in the grid

Thanks
Pratheep

Venkatesh Ayothi Raman [Syncfusion]
Replied On January 20, 2017 10:02 AM UTC

Hi Pratheep, 
Thanks for the update. 
Yes, we can update the quantity value for already existing product code by using same endAdd event in Grid. We have also modified your project. Please refer to the sample and code example for your convenience, 
Code example
function endAdd(args) { 
            var len = this.model.dataSource.length; 
            for (var i = 0; i < len; i++) { 
                if (i != 0 && args.data.Productcode === this.model.dataSource[i].Productcode) { 
                    this.model.dataSource.splice(0, 1); 
                    this.model.dataSource[i - 1].Productname = args.data.Productname; 
                    this.model.dataSource[i - 1].qty = this.model.dataSource[i - 1].qty+args.data.qty; //here we can add the new qty value with existing one. 
                    this.refreshContent(); 
                    return false; 
                } 
            } 
 
        } 

Regards, 
Venkatesh Ayothiraman. 


Pratheep
Replied On January 22, 2017 07:04 PM UTC

Hi Venkatesh Ayothiraman.

Thank for your replay.working fine

Thanks
Pratheep

Venkatesh Ayothi Raman [Syncfusion]
Replied On January 23, 2017 04:28 AM UTC

Hi Pratheep, 
Thanks for the feedback. 
We are very happy to hear that your requirement is achieved. 
Regards, 
Venkatesh Ayothiraman. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;