- Home
- Forum
- ASP.NET Web Forms
- edit and delete lock
edit and delete lock
Thanks for using Syncfusion products.
From your query we suspect that you want to dynamically disable the tollbaritems from the grid which is already discussed in the below KB link,
https://www.syncfusion.com/kb/5450/how-to-disable-or-enable-toolbar-items-in-the-grid
Before proceed with your requirement “Disable toolbaritems by selecting the column” we need below details,
1. Are you want to disable the toolbar item based on the HeaderText/Field name or particular cell value of the selected column?
2. You have mentioned like code behind, did you expect to disable the tool bar items using server side events?
3. Kindly explain your scenario clearly and share the code example that you have tried in your application.
4. Screenshot of the your requirement.
The provided information will help to analyze the issue and provide you the response as early as possible.
Regards,
Gowthami V.
Attachment: Capturedddddddddddddddddddd_71453e14.7z
We can disable the toolbar items using “disableItem” method of the ejToolbar in the RowSelecting event as follows,
|
<ej:Grid ID="Grid" runat="server" AllowPaging="True"> <EditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" AllowEditOnDblClick="false"/> <ToolbarSettings ShowToolbar="true" ToolbarItems="add,edit,delete,cancel"/> <ClientSideEvents RowSelecting="rowselect"/> function rowselect(args) { //Gets the ToolBar. var $toolbar = $("#<%= Grid.ClientID %>_toolbarItems"); if (!args.data.Verified) { // Enables or disables the call based on the status. $toolbar.ejToolbar("disableItem", $("#<%= Grid.ClientID %>_edit")); $toolbar.ejToolbar("disableItem", $("#<%= Grid.ClientID %>_delete")); } else { // Enables or disables the call based on the status. $toolbar.ejToolbar("enableItem", $("#<%= Grid.ClientID %>_edit")); $toolbar.ejToolbar("enableItem", $("#<%= Grid.ClientID %>_delete")); } } |
In the above code example we have disabled the toolbar item using “disableItem” method and enable the toolbar item using “enableItem” method.
[OR]
If you want to use the command column concept as you have used in your previous grid like edit and delete button in the column then we can disable the button based on the row value as follows,
|
<ej:Grid ID="Grid" runat="server" AllowPaging="True" AllowGrouping="true" AllowFiltering="true" AllowSorting="true"> <EditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" AllowEditOnDblClick="false"/> <ToolbarSettings ShowToolbar="true" ToolbarItems="add,edit,delete,cancel"/> <Columns> <ej:Column HeaderText="Manage Column" IsUnbound="True" Width="130"> <Command> <ej:Commands Type="edit"> <ButtonOptions ContentType="ImageOnly" PrefixIcon="e-edit" Text="Edit"></ButtonOptions> </ej:Commands> <ej:Commands Type="delete"> <ButtonOptions ContentType="ImageOnly" PrefixIcon="e-delete" Text="Delete"></ButtonOptions> </ej:Commands> <ej:Commands Type="save"> <ButtonOptions ContentType="ImageOnly" PrefixIcon="e-update" Text="Save"></ButtonOptions> </ej:Commands> <ej:Commands Type="cancel"> <ButtonOptions ContentType="ImageOnly" PrefixIcon="e-cancel" Text="Cancel"></ButtonOptions> </ej:Commands> </Command> </ej:Column> <ej:Column Field="OrderID" IsPrimaryKey="true" Width="90" /> <ej:Column Field="Verified" Width="100" /> <ClientSideEvents RowDataBound="dataBound" Create="create" ActionComplete ="complete"/> </ej:Grid> <script type="text/javascript"> function dataBound(args) { //Adding custom class for the ejButton based on the field Verified if (args.data.Verified) args.row.find("td.e-unboundcell").find(".e-button").addClass("greenClass"); else args.row.find("td.e-unboundcell").find(".e-button").addClass("redClass"); }
function customizeButton() { //Customize the background-colur and text for the ejButton $(".greenClass").ejButton({ enabled:true }); $(".redClass").ejButton({ enabled:false }); } function create(args) { customizeButton(); } function complete(args) { customizeButton(); } </script> |
In the above code example we have disabled the button based on the Verified column value and disabled the editing.
We have created a sample with the above two scenarios and the same can be downloaded from the following link.
http://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample_(2)1490350751.zip
Regards,
Gowthami V.
Hi Alavudeen,
Query 1: I got an answer is perfectly fit to my requirement.
Thanks for your update.
Get back to us if you need further assistance.
Query 2: how to create a tabitems using sql server.
We have provided solution for this query in F123476. So kindly follow-up with the specified forum for more details.
Regards,
Gowthami V.
- 6 Replies
- 2 Participants
-
AL alavudeen
- Mar 18, 2016 06:49 AM UTC
- Mar 23, 2016 02:15 PM UTC