Announcement

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

    Javadoc example Javascript instead of Java / Enhancement suggestion / Hilite question

    Hi Isomorphic,

    please see ListGrid.canEditCell(). The example should be:
    Code:
    @Override
    public boolean canEditCell(int rowNum, int colNum) {
    	Record record = this.getRecord(rowNum);
    	String fieldName = this.getFieldName(colNum);
    	if (fieldName.equals("shipDate") && record.getAttribute("orderStatus").equals("complete") {
    		return false;
    	}
    	// use default rules for all other fields
    	return super.canEditCell(rowNum, colNum);
    };
    Also, the docs have some entries of "${isc." which were not replaced by links. I found those searching the docs in the browser after noticing the isc in the example.

    Enhancement suggestion:
    Could you add a .ds.xml field-level attribute canEditField (must be boolean), which decides on a per-row basis if the current field is editable in the current row?

    This would work like you described it for Hilites:
    Originally posted by docs
    A hilite can be applied to data either by defining criteria or by explicitly including markers on the data itself.
    Please note that I did not find a way to do this "explicitly including markers on the data itself" in the docs.
    Out of interest: How is it done? What to call instead of Hilite.setCriteria()?

    Thank you & Best regards
    Blama
    Last edited by Blama; 2 Sep 2015, 13:02. Reason: == in source replaced by equals("")

    #2
    Thanks for the points about the JavaDocs. We've added the Java sample code you suggested to LG.canEditCell, and will look into the "${isc." tags.

    On the other points:
    It sounds like you're suggesting we have dataSourceField.canEditField which is set to the name of another field in the dataSource, and that other field be of type "boolean".

    We currently have no plans to do this - but it would be easy to achieve in app code by subclassing ListGrid with a custom canEditCell implementation.

    The implementation would
    - get the field based on the colNum
    - check for the attribute "canEditField" being non null / a string
    - if it is, check for the value of that attribute on the record (derived from the rowNum)


    On the Hilite question:
    Please note that I did not find a way to do this "explicitly including markers on the data itself" in the docs.
    Out of interest: How is it done? What to call instead of Hilite.setCriteria()?
    The next paragraph of the javadoc you quoted explains this:
    Hiliting rules that require server-side calculations can be achieved by assigning a id to a hilite definition, and setting the hiliteProperty on the records that should show that highlight. This can be used, for example, to hilite the record with the maximum value for a dataset that the application will load incrementally.
    So basically you'd specify a value on each record for the 'hiliteProperty'. By default this is "_hilite" but could be something else.

    Regards
    Isomorphic Software

    Comment


      #3
      Hi Isomorphic,

      thanks for the fast answer.
      Originally posted by Isomorphic View Post
      Thanks for the points about the JavaDocs. We've added the Java sample code you suggested to LG.canEditCell, and will look into the "${isc." tags.

      On the other points:
      It sounds like you're suggesting we have dataSourceField.canEditField which is set to the name of another field in the dataSource, and that other field be of type "boolean".

      We currently have no plans to do this - but it would be easy to achieve in app code by subclassing ListGrid with a custom canEditCell implementation.

      The implementation would
      - get the field based on the colNum
      - check for the attribute "canEditField" being non null / a string
      - if it is, check for the value of that attribute on the record (derived from the rowNum)
      That is exactly what I'm doing now. I just wanted to add this as Enhancement suggestion.

      For others:
      Code:
      @Override
      public boolean canEditCell(int rowNum, int colNum) {
      	Record record = this.getRecord(rowNum);
      	String fieldName = this.getFieldName(colNum);
      	if (DatasourceFieldEnum.T_FIELD_CONFIG__VISIBLE.getValue().equals(fieldName)
      			|| DatasourceFieldEnum.T_FIELD_CONFIG__REQUIRED.getValue().equals(fieldName)
      			|| DatasourceFieldEnum.T_FIELD_CONFIG__DISPLAYNAME.getValue().equals(fieldName)
      			|| DatasourceFieldEnum.T_FIELD_CONFIG__DESCRIPTION.getValue().equals(fieldName)
      			|| DatasourceFieldEnum.T_FIELD_CONFIG__WIDGETCLASS.getValue().equals(fieldName)
      			|| DatasourceFieldEnum.T_FIELD_CONFIG__DEFAULTVALUE.getValue().equals(fieldName)
      			|| DatasourceFieldEnum.T_FIELD_CONFIG__VALUELIST.getValue().equals(fieldName)
      			|| DatasourceFieldEnum.T_FIELD_CONFIG__ALLOWNONLISTVALUES.getValue().equals(fieldName)
      			|| DatasourceFieldEnum.T_FIELD_CONFIG__MULTIPLE.getValue().equals(fieldName)
      			|| DatasourceFieldEnum.T_FIELD_CONFIG__CLIENTREGEXP.getValue().equals(fieldName)
      			|| DatasourceFieldEnum.T_FIELD_CONFIG__CLIENTREGEXPERRORMESSAGE.getValue().equals(fieldName)) {
      		if (record.getAttribute(fieldName + "_CE") != null)
      			return record.getAttributeAsBoolean(fieldName + "_CE");
      		else
      			return super.canEditCell(rowNum, colNum);
      	}
      	// use default rules for all other fields
      	return super.canEditCell(rowNum, colNum);
      };
      Originally posted by Isomorphic View Post
      On the Hilite question:
      The next paragraph of the javadoc you quoted explains this:

      So basically you'd specify a value on each record for the 'hiliteProperty'. By default this is "_hilite" but could be something else.
      Great, thanks. As far as I understood it I can enable all Hilites for the record that way. So using the criteria system allows for more control (e.g. only hiliting changed field-values between two rows (assuming that I have a (hidden) marker-field per displayed-field). I'm doing the latter right now and it is working. I just wanted to know if there is a more simple way of doing this.

      For others:
      Code:
      public class FieldChangedHilite extends Hilite {
      	public FieldChangedHilite(String fieldName) {
      		super();
      		setFieldName(fieldName);
      		setCriteria(new AdvancedCriteria(new Criterion(fieldName + "_CHG", OperatorId.EQUALS, true)));
      		setCssText("color:#FF0000;");
      	}
      }
      Thank you & Best regards
      Blama

      Comment


        #4
        Quick answers:

        1. we've noted your enhancement request re: controlling editability based on another field, but right now this seems not particularly common, and well-handled by an override of canEditCell, so it's very unlikely we'd add more features here

        2. the way you've created your Hilite is in fact the right way to do it

        Comment

        Working...
        X