Package com.smartgwt.client.widgets.grid

Examples of com.smartgwt.client.widgets.grid.CellFormatter


        final ListGridField valueField = new ListGridField(FIELD_VALUE, MSG.common_title_value());
        valueField.setRequired(propertyDefinitionSimple.isRequired());
        valueField.setCanEdit(true);
        final FormItem editorItem = buildEditorFormItem(valueField, propertyDefinitionSimple);
        valueField.setEditorType(editorItem);
        valueField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                if (value == null) {
                    return "";
                }
                List<PropertyDefinitionEnumeration> enumeratedValues = propertyDefinitionSimple.getEnumeratedValues();
View Full Code Here


        TreeGridField[] fields = new TreeGridField[2 + titles.size()];

        TreeGridField nameField = new TreeGridField("name", MSG.common_title_name(), 250);
        nameField.setFrozen(true);
        nameField.setCellFormatter(new CellFormatter() {
            public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                if (listGridRecord == null || listGridRecord.getAttributeAsBoolean(ATTRIB_ALL_SAME)) {
                    return String.valueOf(o);
                } else {
                    return "<span style=\"color: red;\">" + String.valueOf(o) + "</span>";
                }
            }
        });

        TreeGridField typeField = new TreeGridField("type", MSG.common_title_type(), 80);

        fields[0] = nameField;
        fields[1] = typeField;

        int i = 2;
        for (String title : titles) {
            TreeGridField columnField = new TreeGridField(title, title, 150);
            columnField.setCellFormatter(new CellFormatter() {
                public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
                    if (!(listGridRecord instanceof ComparisonTreeNode)) {
                        return "";
                    } else if (listGridRecord.getAttributeAsBoolean(ATTRIB_ALL_SAME)) {
                        return String.valueOf(o);
View Full Code Here

        //The new value (selected record) is not retrievable (getting it from 'selectedRecord' explodes our stack size... (bug?)
        //And we don't want to use the onchanged handler of the combobox itself (because then on every keypress we check for cors stuff)
        //Therefor, set this flag. The onchanged handler of the combobox can then check and reset this flag and store the endpoint
        pickListRecordSelected = true;
      }});
        pickListProperties.setCellFormatter(new CellFormatter() {
      @Override
      public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
        if (rowNum == 0 && colNum == 0 && Helper.recordIsEmpty(record)) {
          return "Empty";
        }
View Full Code Here

   *
   * @return
   */
  private ListGrid getListGridSearchTable() {
    searchGrid = new ListGrid();
    searchGrid.setCellFormatter(new CellFormatter(){
      @Override
      public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
        if (rowNum == 0 && colNum == 0 && Helper.recordIsEmpty(record)) {
          return "Empty";
        }
View Full Code Here

        public Object normalize(ListGridRecord record, String fieldName) {
          HashMap<String, HashMap<String, String>> bindings = solutions.get(record.getAttributeAsInt(SOLUTION_ATTRIBUTE));
          HashMap<String, String> binding = bindings.get(fieldName);
          return binding.get("value");
        }});
      field.setCellFormatter(new CellFormatter(){
        @Override
        public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
          HashMap<String, HashMap<String, String>> bindings = solutions.get(record.getAttributeAsInt(SOLUTION_ATTRIBUTE));
          HashMap<String, String> binding = bindings.get(var);
          if (binding != null) {
View Full Code Here

        ListGridField nameField = new ListGridField("countryName", "Country");
        ListGridField capitalField = new ListGridField("capital", "Capital");
        ListGridField populationField = new ListGridField("population", "Population");
        populationField.setType(ListGridFieldType.INTEGER);
        populationField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                NumberFormat nf = NumberFormat.getFormat("0,000");
                try {
                    return nf.format(((Number) value).longValue());
                } catch (Exception e) {
View Full Code Here

                new TreeNode("Favourites")));

        treeGrid.setData(data);
       
        TreeGridField field = new TreeGridField("Navigation");
        field.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                return record.getAttribute("name");
            }
        });
        treeGrid.setFields(field);
View Full Code Here

        ListGridField nameField = new ListGridField("countryName", "Country");
        ListGridField capitalField = new ListGridField("capital", "Capital");

        ListGridField populationField = new ListGridField("population", "Population");
        populationField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                if (value == null) return null;
                try {
                    NumberFormat nf = NumberFormat.getFormat("0,000");
                    return nf.format(((Number) value).longValue());
                } catch (Exception e) {
                    return value.toString();
                }
            }
        });

        ListGridField areaField = new ListGridField("area", "Area (km&sup2;)");
        areaField.setType(ListGridFieldType.INTEGER);
        areaField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                if (value == null) return null;
                String val = null;
                try {
                    NumberFormat nf = NumberFormat.getFormat("0,000");
                    val = nf.format(((Number) value).longValue());
                } catch (Exception e) {
                    return value.toString();
                }
                return val + "km&sup2";
            }
        });
        countryGrid.setFields(countryCodeField, nameField, capitalField, populationField, areaField);

        //create another grid to display the preference name and viewState string
        final ListGrid preferecesGrid = new ListGrid();
        preferecesGrid.setHeight(300);
        preferecesGrid.setWrapCells(true);
        preferecesGrid.setFixedRecordHeights(false);
        preferecesGrid.setCanEdit(true);
        preferecesGrid.setEmptyMessage("No Saved Preferences");
        preferecesGrid.setSelectionType(SelectionStyle.SINGLE);
        preferecesGrid.setCanRemoveRecords(true);
        final ListGridField name = new ListGridField("name", "Preference");
        ListGridField viewState = new ListGridField("viewState", "View State String");
        viewState.setEditorType(new TextAreaItem());
        viewState.setCellFormatter(new CellFormatter() {
            @Override
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                //prettier display
                return ((String) value).replace("\\r", "");
            }
View Full Code Here

        ListGridField nameField = new ListGridField("countryName", "Country");
        ListGridField nationHoodField = new ListGridField("independence", "Nationhood");
        nationHoodField.setType(ListGridFieldType.DATE);

        final DateTimeFormat dateFormatter = DateTimeFormat.getFormat("MMM d, yyyy");
        nationHoodField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                if (value != null) {

                    try {
                        Date dateValue = (Date) value;
                        return dateFormatter.format(dateValue);
                    } catch (Exception e) {
                        return value.toString();
                    }
                } else {
                    return "";
                }
            }
        });

        ListGridField areaField = new ListGridField("area", "Area (km&sup2;)");
        areaField.setType(ListGridFieldType.INTEGER);
        areaField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                if(value == null) return null;

                String val = null;
                try {
View Full Code Here

        ListGridField nameField = new ListGridField("countryName", "Country");
        ListGridField continentField = new ListGridField("continent", "Continent");
        ListGridField memberG8Field = new ListGridField("member_g8", "Member G8");
        ListGridField populationField = new ListGridField("population", "Population");
        populationField.setType(ListGridFieldType.INTEGER);
        populationField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                if(value == null) return null;
                NumberFormat nf = NumberFormat.getFormat("0,000");
                try {
                    return nf.format(((Number) value).longValue());
View Full Code Here

TOP

Related Classes of com.smartgwt.client.widgets.grid.CellFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.