Announcement

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

    EmptyCellValue Not working with ListGridFieldType.LINK

    Hi,
    I'm using latest smartgwt ie., smartgwt3.1p version. In list grid, i want to display one column's, empty cell value as HyperLink with a cellClickHandler attached to it.

    So i've used like below:
    Code:
          ListGridField linkField = new ListGridField("linkName", "Status");
            linkField.setType(ListGridFieldType.LINK);
            linkField.setTarget("javascript");
            linkField.setEmptyCellValue("Show Status");
    but it is displaying as plain text instead of hyper link. Clickhandler is getting invoked but i need to display that text as hyper link.

    I've created a test case by taking showcase example. Please check once.
    Attached Files

    #2
    Were you expecting the emptyCellValue to be displayed as a link? It doesn't, and that's by design.

    If you need a different behavior, you can define a CellFormatter and output your own HTML <a> tag based on whatever rules you prefer.

    Comment


      #3
      Hi Isomorphic,
      Thanks for the reply.
      May i know the reason why it is like that?

      In listgrid, i can define one extra field ( like the one i showed above, which is just an extra field with the same value in all rows but to be displayed as hyper link) which may not be part of my data coming from server.

      For this same value (which won't be der in records), emptyCellValue works fine otherwise i need to iterate over all the records and set this additional property as, Show Status. But i don't think so this is a good approach.

      Similary i want to add another columnn, with EDIT in all rows.

      Coming to your suggestion, i tried your approach. It is displaying as hyper link but when i click that link, it is not calling .cellClickHanlder which i wrote on list grid for this column.

      I've used as shown below:
      Code:
      linkField.setCellFormatter(new CellFormatter() {
      			
      			@Override
      			public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
      				return "<a href='javascript:void()'> Show Status</>";
      			}
      		});
      How to call cellClickHandler here?

      Comment


        #4
        emptyCellValue works fine for link fields, it just doesn't generate a link because that doesn't make sense for most values of listGridField.target (would have a blank URL).

        To understand how to call GWT code from JavaScript, read the core GWT documentation on JSNI.

        Comment


          #5
          I still even couldn't under stand, why it doesn't make sense displaying emptyCellValue as hyperlink.

          As i'm explicitly specifying ListGridFieldType as LINK for field, i think framework should consider this or atleast provide another boolean kind of method like showEmptyCellValueAsLink(true or false) otherwise there is no point of specifying it as LINK.

          If i realy don't need LINK, i won't even specify it, will just go default value which is TEXT..right..

          Anyways, thanks for the replies. Will study the documentation to know how to call GWT code from JS.
          Last edited by skaluva; 15 Mar 2013, 11:17.

          Comment

          Working...
          X