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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How implement Lock Row

Thread ID:

Created:

Updated:

Platform:

Replies:

144744 May 20,2019 11:53 PM UTC May 23,2019 03:38 PM UTC ASP.NET Web Forms 6
loading
Tags: Grid
Alfonso
Asked On May 20, 2019 11:53 PM UTC

Good day.

I need your support, I want to implement an example of "Lock Row"(https://asp.syncfusion.com/demos/web/grid/lockrow.aspx) in my project without dropdownlist that used in the example, consists of certain rows with specific content that will be blocked and can't be edited and other rows that can be edited i want runs automatically when the Grid has Binded.

in the image put weren't  row can be edited who data your valour be > 0 (Zero)

Add my code and an img of my project.

Thank you and thank you for your support.


Attachment: LockRow_47e39fb9.7z

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On May 21, 2019 11:24 AM UTC

Hi Alfonso, 
 
Thanks for contacting Syncfusion Support. 
 
Query#:- specific content that will be blocked and can't be edited and other rows that can be edited i want runs automatically when the Grid has Binded. 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query and  achieved your requirement through BeginEdit event of the Grid. In the BeginEdit event based on the value of the row, we have set args.cancel as true to prevent Editing for that row while on rendering of Grid. 
 
Please refer to the code example:- 

<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" OnServerEditRow="EditEvents_ServerEditRow">  
            <ClientSideEvents ActionComplete="complete" BeginEdit="beginEdit" EndEdit="endEdit" /> 
            <Columns> 
                <ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="Right" Width="75" /> 
                <ej:Column Field="ShipCity" HeaderText="Ship City" Width="120" /> 
                  .     .    . 
            </Columns> 
                    </ej:Grid> 
          
    
   <script type="text/javascript"> 
        
        function beginEdit(args) { 
              if(args.rowData.EmployeeID > 3){  //Change as per your fieldName value 
                     args.cancel = true; 
           } 
        }          
    </script> 
        

Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 


Alfonso
Replied On May 21, 2019 09:19 PM UTC

Hello, good day.

Thank you for your answer your code can be adapting very well  and works great; but and now i have a one more question.

How change a default value that show, than the result only shows the first data in the cell that can be edited for the grid without respecting the record to be edited.

i'll attach the code and img  the show them my cuestion.

Thank you for your supporting





Attachment: LockRow2_652f1d52.7z

Alfonso
Replied On May 22, 2019 12:08 AM UTC

Hello, good day.

Thank you for your answer your code can be adapting very well  and works great; but and now i have a one more question.

How change a default value that show, than the result only shows the first data in the cell that can be edited for the grid without respecting the record to be edited.

i'll attach the code and img  the show them my cuestion.

Thank you for your supporting





Attachment: LockRow2_652f1d52.7z

and  one thing more.

i can was set focus row on the first position of the grid when load the grid, can be done?

Grettings.

Vignesh Natarajan [Syncfusion]
Replied On May 22, 2019 08:33 AM UTC

Hi Alfonso,   
  
Thanks for the update.   
  
Query:1 “How change a default value that show, than the result only shows the first data in the cell that can be edited for the grid without respecting the record to be edited.  
  
From your query, we understand that you are facing issue (getting first record values instead of corresponding record value) while editing a record. We have already discussed this topic in our knowledge base document. Kindly refer the below link for the knowledge base document.  
  
  
We have analyzed the provided code example and found that you have used multiple IsPrimaryKey and also their values are not unique. For editing action, PrimaryKey column must be defined and its value must be unique. Since your primaryKey values are not unique reported issue, occur.   
  
Kindly ensure to define the primaryKey property to column which has unique values.   
  
Query2: “i can was set focus row on the first position of the grid when load the grid, can be done?  
  
As we quite unclear about your requirement, kindly share the following details which will be helpful for us to validate the reported query at our end.   
  
  1. Do you want to select the first record by default?  
  1. Or do you want to focus the first cell while editing a record?  
  1.  If not share more details about your requirement.  
  
Regards,  
Vignesh Natarajan.  


Alfonso
Replied On May 22, 2019 02:47 PM UTC

Query2: “i can was set focus row on the first position of the grid when load the grid, can be done?  
  
As we quite unclear about your requirement, kindly share the following details which will be helpful for us to validate the reported query at our end.   
  
  1. Do you want to select the first record by default?  <-- i want this...
  1. Or do you want to focus the first cell while editing a record?  
  1.  If not share more details about your requirement.

  2.  
  3. i send you video who demonstrate were a i want

Attachment: LockRow_d4b2794c.7z

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On May 23, 2019 03:38 PM UTC

Hi  Alfonso, 
  
Do you want to select the first record by default?  <-- i want this... 
 
Solution#1:- 
We have checked your query and if you want to select the firstRecord by default you can use selectRows method of the Grid on DataBound event of the Grid.  
 
Solution#2:- 
Otherwise you can use SelectedRowIndex property of the Grid on rendering of the Grid. Please refer to the code example:- 
 
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" SelectedRowIndex="0" EnableHeaderHover="True"> 
           <ClientSideEvents DataBound="bound" /> 
            <Columns> 
                <ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="True" AllowEditing="false" TextAlign="Right" Width="90" /> 
            </Columns> 
             
       <script type="text/javascript"> 
           function bound(args) { 
               this.selectRows(0); 
           } 
       </script> 

Please ensure that you have used the above solution in your sample. After following this solution still facing the issue, please share us the following details. 

  1. Complete Grid code example(both in server and client side).
  2. Exact scenario you have faced the issue.

Regards, 

Farveen sulthana T 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon