Announcement

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

    Display link in ListGrid with custom behavior

    Hi,

    We are using SmartGWT Pro 3.0 version.
    In ListGridField if I set the field type as "Link" it displays the cell data as link but on click of that it try to open that link in new window.

    I want to display few fields as Link and on Click of those links I want display some custom pop-ups.

    Please let me know how I can do this.

    Thanks

    #2
    See docs for ListGridFieldType LINK and ListGridField.target.

    Comment


      #3
      I already went through the doc and tried but its not working, I set the target value as null, empty string but still it is opening in new window, also I didn't found how to add the link click handler.

      Comment


        #4
        Hmm. What the docs actually say is to set the target to "javascript" then add a CellClick handler. Did you try that?

        Comment


          #5
          hi

          I have set the target to "javascript" but it doesn't work as a link, ie., while cursor changes to hand-symbol rather it works on just cell click when cursor is in normal arrow pointer not as link.

          what to do? we need to navigate on link type.

          Comment


            #6
            Sorry, we can't follow what the problem is. Please try explaining again.

            Comment


              #7
              Hi,

              we have set the field settarget to "javascript".

              But it doesn't work as a hyperlink, (ie) it is not working during the mouse pointer turns into to linksymbol(hand icon).

              Rather than that it works on cell click when the mouse pointer changes back to normal(arrow icon).

              we need it to be work on hyperlink.

              Attached a screenshot.
              Attached Files
              Last edited by fairoz172; 15 Dec 2012, 01:46. Reason: spell mistake

              Comment


                #8
                Here's an example that should demonstrate this working.
                If you still can't get your expected behavior within the app, please show us a test case we can run and describe your expected behavior (and what you're seeing instead)

                Thanks
                Isomorphic Software
                Code:
                isc.ListGrid.create({
                    ID:"testGrid",
                    data:[{a:"1", b:"2"}],
                    fields:[
                        {name:"a"},
                        {name:"b", type:"link", target:"javascript"}
                    ],
                    cellClick:function (record,rowNum,colNum) {
                        if (this.getFieldName(colNum) == "b") {
                            alert(1);
                         }
                    }
                });

                Comment


                  #9
                  Hi,

                  sorry i didn't get.
                  our bug is the grid filed's content is not working as a hyperlink even i have set the setTarget("javascript"). it just working as on grid's cellclick event.

                  the sample code is:

                  ListGridField firstField = alertGrid.getField(Constants.BANK_ALERTS_BANK_ALERT_PROFILE_ID);
                  firstField.setType(ListGridFieldType.LINK);
                  firstField.setTarget("javascript");

                  alertGrid.addCellClickHandler(new CellClickHandler()
                  {
                  @Override
                  public void onCellClick(CellClickEvent event)
                  {
                  ListGridField field = alertGrid.getField(event.getColNum());
                  String fieldName = field.getName();
                  if (fieldName.equals(Constants.BANK_ALERTS_BANK_ALERT_PROFILE_ID))
                  {
                  int profileId = bankAlertsGrid.getSelectedRecord().getAttributeAsInt(Constants.BANK_ALERTS_BANK_ALERT_PROFILE_ID);
                  displayProfileDetailPopUp(profileId);
                  }
                  }
                  });
                  Last edited by fairoz172; 16 Dec 2012, 21:52.

                  Comment


                    #10
                    This request isn't making any sense to us.

                    If you want a "link" field to behave like a normal web link and open a new page, that's the default behavior, just don't set anything.

                    If you want it to call your code instead, set the target to "javascript" and use the CellClick event.

                    These behaviors are mutually exclusive (you can't have both).

                    If you want something else entirely, use a CellFormatter to output your own HTML cell contents.

                    Comment


                      #11
                      hi,

                      our issue is, the link is not calling the cellclick event on clicking the hyperlink.

                      thanks

                      Comment


                        #12
                        Once again:
                        - if you use linkType "javascript", CellClick will be called
                        - if you do not use linkType "javascript", CellClick will not be called, and this is by design (the browser is handling the link directly).

                        Comment


                          #13
                          Hi,

                          Sorry the problem is not yet solved.

                          i have set setTargert to javascript.

                          but hyperlink is not working. On clicking hyerlinked content it is not calling cell click event.

                          then clicking in the cell not in the hyperlinked content is default calls cell click event.

                          then what is the solution to make the cell click call on clicking Hyperlinked content.

                          Thanks

                          Comment


                            #14
                            We've already tested this functionality and it works as expected.

                            Most likely there is something else in your code, or perhaps some third party library you are using, that is interfering with the normal operation of this feature.

                            If you think you've found a bug in SmartGWT, please put together a minimal, ready-to-run test case demonstrating the issue.

                            Comment


                              #15
                              We realize some of the confusion here may be coming from the fact we posted a Javascript / SmartClient example rather than a SmartGWT example.
                              Here's a snippet of SmartGWT script showing this working for us

                              Regards
                              Isomorphic Software

                              Code:
                              public class ListGridLink implements EntryPoint {
                              
                                  @Override
                                  public void onModuleLoad() {
                                      ListGrid grid = new ListGrid();
                                      grid.setData(
                                              new ListGridRecord[] {
                                                  new ListGridRecord() {{ setAttribute("a", "1"); }},
                                                  new ListGridRecord() {{ setAttribute("b", "2"); }}
                                              }
                                      );
                                      
                                      grid.setFields(
                                              new ListGridField("a"),
                                              new ListGridField("b") {{
                                                  setType(ListGridFieldType.LINK);
                                                  setTarget("javascript");
                                              }}
                                      );
                                      
                                      grid.addCellClickHandler(new CellClickHandler() {
                                          
                                          @Override
                                          public void onCellClick(CellClickEvent event) {
                                              String fieldName = ((ListGrid)event.getSource()).getFieldName(event.getColNum());
                                              if ("b".equals(fieldName)) {
                                                  SC.say("Clicked on field b!");
                                              }
                                          }
                                      });
                                      
                                      grid.draw();
                                  }
                              
                              }

                              Comment

                              Working...
                              X