1

can somebody please help me with making readonly rows in Quick edit view in sharepoint 2013. There are readonly column using AllowgridEditing = false but there seems to be no possible way to make readonly rows. (edit: Iam trying to achieve it using javascript. So when list is loaded certain rows to be made readonly based on some values in a particular cell of that row)

  • Hi Manoj, Are you using JavaScript – san Sep 15 '17 at 10:45
  • Yes , i am using js in script editor web part. – Manoj Sep 18 '17 at 3:25
2

You can set few fields as read-only in a Quick edit / Datasheet mode of a List view through Sharepoint designer.

  1. Create a List view with all the required fields (Including Read only and editable fields) and by applying required filters
  2. Now, open the List in sharepoint designer and edit the Newly created list view file in 'Advanced Mode'. You can do it be right clicking on the View Name in the List
  3. In the file, go to 'XMLdefinition' tag, inside that you can see 'ViewFields' section where all the fields added in step 1 are available.
  4. For all the read only fields, you add ReadOnly="TRUE" attribute in the corresponding FieldRef tag.
  5. So, a Field ref tag for a read only field would be as <FieldRef Name="Product" ReadOnly="TRUE"/>
  6. Now save the file and open it in browser.
  7. Once you go to Quick Edit, you can see the read only columns are disabled. enter image description here
  • Thanks @chinna for prompt reply and i am so sorry for not being clear first time. i have edited it. i would've wanted to achieve this using js and make Cells readonly if the row contain any value. for eg. in your snap, if WorkRequest = "Sample Request" then make "New Component Item 0" and "150" readonly. – Manoj Sep 16 '17 at 3:46
0

I have managed to make cells readonly. I am disabling keys to prevent editing. here is the script :

(It is just a workaround for now but if you have any other answers Please let me know. Thanks)

        $(document).on("keydown", ".ms-listviewtable", function (m) {
                            var currentUser = $(".ms-listviewtable.ms-listviewgrid").find(".ms-jsgrid-cell-selected-editable").parent().find("td").eq(7).text().trim();

                            if(currentUser == "Piping"){
                                                            m.preventDefault();
                                                            alert("editing not allowed");
                            }

                });

        $(document).on("mouseup", "#jsgrid_combobox", function (e) {
            var editable = $(".ms-jsgrid-cell-selected-editable");
            if (editable.parent().find("td").eq(7).text() == "Piping") {
                $(document).on("click", "#jsgrid_combobox input,.combobox-dropdown", function (e) {
                    $e.preventdefault();
                });
                $(document).on("keyup", "#jsgrid_combobox input", function (e) {
                    $e.preventdefault();
                });
                $(this).find("input").prop("disabled", true);

                alert("You can not edit");
            } else {
                $(document).on("click", "#jsgrid_combobox input", function (e) {
                    $(this).unbind("click");
                });
                $(document).on("keyup", "#jsgrid_combobox input", function (e) {
                    $(this).unbind("keyup").keyup();
                });
                $(this).find("input").prop("disabled", false);
            }


        })

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.