Disable Multi-Row Editing for Specific Fields?

Disable Multi-Row Editing for Specific Fields?

hullchullc Posts: 10Questions: 3Answers: 1

Is it possible to disable multi-row edit support only for specific fields? Ideally I'm looking for a way that wouldn't just block the multi-row edit after the user enters data but instead inform the user at the form level that that field is unavailable for multi-row editing (but still available for single-row edits). Does this exist in Editor 1.5.6/DT 1.10.11? Is it planned for a future release?

Thanks!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi,

    Thanks for your question. I'm afraid there isn't an option for that built in at the moment - to be honest I think its the first time I've had such a feature request and I hadn't considered this situation before.

    What you could do is listen for initEdit and check how many rows are being edited (modifier() and rows() - table.rows( editor.modifier() ).count() for example) - if multiple then use hide() to hide the fields you don't want to be multi-row edited - show() to make them visible on a single row edit).

    Regards,
    Allan

  • burncharburnchar Posts: 118Questions: 12Answers: 0
    edited July 2016

    A common use-case that I think will require this functionality at some point is in editing a unique database field.
    For example, if I want to edit a SerialNum or LicensePlateNumber field.

    Hiding unique fields wouldn't work because it would disallow edits of sequences. For example, I want to set the SerialNum field of 10 rows to the values 1,2,3...10 (which Editor supports nicely).
    Perhaps setting the field description to "Cannot set multiple rows to the same value"?

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Is leaving the field in its "Multiple values" UI state not an option? You are basically looking for a way to force the multiple values to remain as is, and not have an option to click on it to modify the value, but at the same time hiding it isn't valid either?

    I can see how that might be useful and will look into it for the next release. Thanks for the suggestion!

    Allan

  • burncharburnchar Posts: 118Questions: 12Answers: 0

    From the user's perspective, leaving the "Multiple values" field as is invites them to make an edit that will never succeed.
    Unique fields can be edited individually, but what makes sense for multi-row edits? I cannot think of a satisfying UI design that would allow allow these edits.

    So what should the user see?

    It makes the most sense to me for them to see a message stating that the field supports only single-row edits, customizeable through language.
    The dotted text field looks good as it is now, but make it dimmed (disabled), and with different text. Rather than:

    "Multiple values
    The selected items contain different values for this input. To edit and set all items for this input to the same value, click or tap here, otherwise they will retain their individual values.
    "

    Something like:
    "Multiple values
    This field can be edited individually, but not as part of a multi-row edit.
    "

    Broadly speaking, it seems appropriate for an Editor user to be able to easily distinguish multi- from single- row edits. There can be any number of reasons that could turn up.

    Adding fields.multipleEditable or similar would solve the immediate concern, and it does make sense to me that certain fields would be non-editable in a multi-row edit for uniqueness and other reasons (perhaps the field is used to calculate values for other fields, etc.) It may be more flexible to make a callback for multi- and single- edits, or to pass in an entire object to set field options for multi- vs single- vs some future other type of edit.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Very good point about fields - I hadn't fully comprehended that before, but its fairly obvious now that you restate it - thanks!

    I'll add a fields.multipleEditable (I prefer your name over my noMultiEdit) option for fields in 1.6 and a suitable language option.

    Regards,
    Allan

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi,

    Just a quick update on this. I've committed a new feature to Editor for this which will be included in the 1.6 release that I expect to drop at the start of December. The new option will be called fields.multiEditable and a simple screenshot of it being used is attached.

    Thanks so much to you both for your feedback and suggestions on this!

    Regards,
    Allan

  • amoso.misoamoso.miso Posts: 5Questions: 0Answers: 0
    edited January 2017

    I noticed that the multiEditable option is not working the way I expected it to work.

    When I select an single row and edit it, it still does not let me edit the field that was set to "multiEditable".

    I verified that this behavior is also in one of the examples and not just in my own code: https://editor.datatables.net/examples/extensions/rowReorder.html

    Allan

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Yes, this appears to be a bug that slipped through I'm afraid. {This thread](/forums/discussion/39941) is the one I'm using to track the fix.

    Allan

This discussion has been closed.