Editing a form with inline editing on the same jqgrid

I have one scenario in which I want to apply both form editing and inline editing for the same jqgrid. I have two users, for example, one Admin ID and the other a user and the company jqgrid. Now I want to apply form editing for the administrator and inline editing for the Jqgrid user. I use JSP scripts to indicate if it is Admin or User.

Does anyone know how I can implement this?

@updated:

onSelectRow: function(id){ var userType='<%=userDetails[1]%>'; alert("userType= " + userType); if(userType === 'Company Administrator'){ jQuery('#companyList').jqGrid('editRow',id,true,inlineEditSuccess); } } 
+4
source share
1 answer

The implementation seems clear to me. You just need to specify a JavaScript variable on the server side that will describe which editing mode the user can use. You can even allow editing a user, but not another.

If you do not want to allow any form editing for some use, you can check the value of the corresponding variable, and the call to navGrid depends on the value:

 if (my.formEditing) { $("#list").jqGrid('navGrid', '#pager', ....); } 

or you can use

 if (my.formEditingOn) { $("#list").jqGrid('navGrid', '#pager', {edit: my.formEditOn, add: my.formAddOn, add: my.formDelOn}, ....); } 

If you use the trick described in the answer (see demo ) you can call "navGrid" and create all the buttons of the navigator, but only the visible visible buttons depend on the user rights.

In case of using inline editing you can use something like

 onSelectRow: function (id) { if (!my.inlineEditing) { return; } //... $(this).jqGrid('editRow', id, ...); } 

The initialization of the my variable may vary depending on the technology you are using on the server side. In the simplest variable, my can be defined as global on the page so that it can be defined at the top level. In the case of ASP.NET MVC, the code might look like this:

 <%@ Page ... ... <asp:Content ID="Content3" ContentPlaceHolderID="head" runat="server"> <%-- first include script which defines global my object based on the user rights --%> <script type="text/javascript"> // initialize my based of Model properties filled var my = { inlineEditing : .., formEditOn : ..., formAddOn : ..., formDelOn : ... } </script> <%-- now include the main script which uses jqGrid --%> <script type="text/javascript" src="<%= Url.Content(scriptPath) %>"></script> 
+1
source

Source: https://habr.com/ru/post/1381628/


All Articles