Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Setting fieldError with active grouping

    Hey guys,

    I’m currently trying to implement a listgrid which may group and also can set fieldErrors if needed. While implementing I encountered some problems.

    When an error occurs, I’d like to put it to the correlated cell. Here for I search the listgrid for the correlated record and its column number. Afterwards I try to set the field error with listgrid.setFieldError(theColNum, theFieldName, theErrorMessage). And thats the point where the issue occurres.

    This works fine if the record in which i want to set the fielderror is visible:


    If the record, the field error should be set to, is inside a collapsed group, the method listgrid.getRecordIndex() will answer -1, which indeed makes sense (because it’s not visible). But when needing a correct column number to set a field error, there should be a way to get a correct index or identifier.

    Another option would be to call a method which automatically opens all displayed groups or opens the group of a specific record. But this is not implemented.

    Furthermore I think, using the record instead of the column number would be much easier in this case. But it seems that this function is not implemented (yet).


    Code:
    isc.ListGrid.create({
    	"ID" : "listGrid",
    	"width" : "100%",
    	"height" : "100%",
    	“canEdit” : true,
    	"fields" :
    	[{
    			"name" : "uniqueID",
    			"hidden" : true
    		}, {
    			"name" : "name"
    		}
    	],
    	"groupByField" : "name",
    	"data" : [{
    			"uniqueID" : 1,
    			"name" : "One"
    		}, {
    			"uniqueID" : 2,
    			"name" : "Two"
    		}
    	]
    });
    isc.Button.create({
    	"title" : "Set field error",
    	"left" : "60px",
    	"top" : "120px",
    	"action" : function () {
    		listGrid.setFieldError(listGrid.getRecordIndex(listGrid.data.find("uniqueID", 2)), "name", "An errorMessage");
    	}
    })
    Best Regards

    #2
    Hey guys,

    are there any news about this?
    Do you need more information about the described behavior?

    Thanks for your response.

    Best Regards

    Comment


      #3
      One option for this would be to explicitly open the parent of the node (reveal it in the group tree) before setting the error - like this:

      Code:
      isc.ListGrid.create({
      	"ID" : "listGrid",
      	"width" : "100%",
      	"height" : "100%",
      	"canEdit" : true,
      	"fields" :
      	[{
      			"name" : "uniqueID",
      			"hidden" : true
      		}, {
      			"name" : "name"
      		}
      	],
      	"groupByField" : "name",
      	"data" : [{
      			"uniqueID" : 1,
      			"name" : "One"
      		}, {
      			"uniqueID" : 2,
      			"name" : "Two"
      		}
      	]
      });
      isc.Button.create({
      	"title" : "Set field error",
      	"left" : 60,
      	"top" : 120,
      	"action" : function () {
                  var groupTree = listGrid.groupTree;
                  var record = groupTree.find("uniqueID", 2),
                      parent = groupTree.getParent(record);
                  groupTree.openFolder(parent);
                  listGrid.setFieldError(groupTree.indexOf(record), "name", "An errorMessage");
      	}
      })
      Regards
      Isomorphic Software

      [EDIT: Also - your original code specified your button's left/top coordinates using css-style strings. This is actually not correct, you should be using integers for this -- though we will automatically handle this by converting from a string like "120px" to the numeric value 120]
      Last edited by Isomorphic; 6 Mar 2015, 10:57. Reason: Added note about numeric vs css-style left/top attribute values

      Comment


        #4
        A follow up with a little more detail:
        Having unsaved edit values / validation errors with hierarchical data (TreeGrids), or grouped ListGrids is fundamentally a little tricky in terms of providing a good user experience, as it is hard to provide feedback indicating that there are errors on hidden nodes which the user needs to resolve.

        As such we generally don't recommend autoSaveEdits:false mode with hierarchical data - or if it is a requirement, we recommend ensuring validation occurs on change or row exit even if autoSaveEdits is false, so the user gets immediate feedback for validation failure while the record being edited is still visible.

        The framework APIs aren't geared particularly toward dealing with "hidden" validation errors. We don't support an API to set errors programmatically on hidden rows, for example, as the user will not be able to see them. Our recommendation of simply opening the tree before setting errors stands as the best way to address this sort of thing.

        There are ways that a grid could provide user-feedback for hidden validation errors - probably the best user-experience for this would be to have something like a special status icon on parents of hidden nodes with errors, with a click handler or context menu allowing the user to auto-expand the tree and jump to those errors.
        We don't currently have anything like this built into the framework, but it would be possible to add some framework APIs to allow this, and explicitly deal with hidden edit-values and validation errors in general.

        This is not something we currently have planned, but if it's something you'd like prioritized, it would be a valid candidate for feature sponsorship. Let us know if you're interested and we could pin down the features in question and come up with an estimate for you.

        Regards
        Isomorphic Software

        Comment

        Working...
        X