Announcement

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

    Hilite Query

    Hello,

    I am using smartgwt 2.4 and have been using the hilite functionality, which is excellent.

    I was wondering if someone could give me some advice please.

    So far we have been using it in situations similar to the showcase examples and it all works fine. However, what we have is a list grid which, when certain users edit the data, asks for a note on why the data has changed. This is all fine and the data is entered into the database table. Once a note has been logged it is then displayed when the user hovers above the cell.

    What we would really like to be able to do is to hilite all cells which have been edited.

    We have tried many things but although I can set the record to have the _hilite property set, I can't see any way of singling out the cell. I have also tried using the criteria but as the data its self has no indication that it has been edited there is no applicable criteria.

    Does anyone know of anyway that we could highlight single cells based on a datasource query?

    We are coding in java and using a mysql database.

    Yours in anticipation...

    Jeni

    #2
    This is very straightforward - if you want to use the hiiite system, just put a property on each Record indicating it's been edited, and use the hilite system to define a Hilite that targets those records. Another straightforward approach is to use getCellCSSText() instead to just apply extra CSS to each edited cell (see Showcase sample). Finally, the autoSaveEdits:false feature provides this feature automatically for typical cases of editing.

    You were pretty vague on exactly what you've tried and what's going wrong - provide more details if you can't get it working using the above information.

    Comment


      #3
      Hello,
      Thank you very much for your prompt reply.

      I have done as you say and have the hilites working beautifully where the criteria is based on the data in a cell.

      Sorry, I probably didn't explain myself very well.

      What I would like to do is highlight a cell which has been edited. The only way we know that it has been edited is that there is a corresponding entry in the log table. So we display the log when the user hovers over the cell which is fine because I can then do a fetch on the log datasource with the relevant criteria using the getCellHoverComponent method.

      I can set the hilite on the record when the data is fetched if there is a cell in that record that has been edited but I can't then see how to define which cell to hilite.
      What I am not sure about is if it is possible to apply a hilite to that cell if the highlighting of the cell is based on the results of a query on the log datasource rather than on the data in the cell.

      Is this possible?

      I have attached a small screen shot of the grid, the circled cell is the one that has been edited and it shows the log entry as the mouse is hovering over the field. What I would like is this cell to be highlighted if possible. The screen shot is from our test app!

      Kind Regards
      Jeni
      Attached Files

      Comment


        #4
        Well no, you can't hilite based on remote data because that would require the remote data to be loaded for every cell, which is tantamount to putting an extra property on each Record indicating it was edited in the first place, and making the log message part of the Record itself instead of loading remotely on hover.

        Comment


          #5
          Ok, thank you.

          Comment


            #6
            i am trying to load data from xml file.
            i have datasource and datafields...and listgrid & listgridfields..

            i have defined hilite and trying to setAttribute(hiliteproperty, id) for each listgridfield....not working so far...

            i am tryint match the string

            for example

            Hilite hilite = new Hilite();
            hilite.setFieldNames("Performance");
            hilite.setCriteria(new Criterion ("performance", OperatorId.EQUALS, "pass"));
            hilite.setCssText("color:#3333FF;background-color:green;");
            hilite.setId("0");


            ListGridField[] dbfield = new ListGridField[dbstr.length];

            for (int f=0; f<dbstr.length; f++)
            {
            dbfield[f]=new ListGridField(dbstr[f]);
            dbfield[f].setShowHover(true);
            }

            dbfield[9].setAttribute("_hilite", "0"); //This is the 'performance' field

            please let me know the mistake i am doing and possible solution...thanks in advance

            Comment


              #7
              You either use Criteria to identify the records to be hilited, or you set the hilite property on the records, not both.

              Just ensure the records actually have the data value you're using in the criteria.

              Comment


                #8
                I am very much new to smartgwt....sorry for my questions

                i think now you understood what i am trying to do
                i have a listgrid with all the fields and i wanted to hilite fields which has "pass" as cell content...

                the way i do as mentioned above is not working and i have tried deleting the below part
                dbfield[9].setAttribute("_hilite", 0);

                and added this dblgrid.enableHilite("0");

                Could you please let me know the solution....thanks in advance

                Comment


                  #9
                  The hilite configuration appears to be fine, the problem is most likely that the data is not correct. But you haven't shown the data.

                  Comment


                    #10
                    you mean the xml file

                    Comment


                      #11
                      here is my entire code....could you please let me know the mistake and solution.....i am a student and i am struggling for this from last two days...please help me

                      ListGrid dblgrid = new ListGrid();
                      dblgrid.setSize("100%","100%");
                      dblgrid.setAutoFitData(Autofit.BOTH);
                      dblgrid.setCanEdit(false);
                      dblgrid.setCanSort(false);
                      dblgrid.setAutoFetchData(true);
                      dblgrid.setShowFilterEditor(true);
                      dblgrid.setGroupStartOpen(GroupStartOpen.ALL);//Change this as FIRST as we want only recent to be open
                      dblgrid.setCanGroupBy(false);
                      dblgrid.setCanPickFields(false);

                      String[] dbstr = new String[]{"id", "product", "performance"};

                      RestDataSource dsdb = new RestDataSource();
                      DataSourceField[] dsfield = new DataSourceField[dbstr.length];
                      for (int d = 0; d<dbstr.length; d++)
                      {
                      dsfield[d]=new DataSourceField(dbstr[d],FieldType.TEXT/*, dbstr[d]*/);
                      }
                      dsfield[0].setPrimaryKey(true);
                      dsdb.setFields(dsfield);
                      dsdb.setDataFormat(DSDataFormat.XML);

                      OperationBinding fetchd=new OperationBinding();
                      fetchd.setOperationType(DSOperationType.FETCH);
                      fetchd.setDataProtocol(DSProtocol.GETPARAMS);

                      dsdb.setOperationBindings(fetchd);

                      dsdb.setFetchDataURL("/sampledb.xml");

                      Hilite hilite = new Hilite();
                      hilite.setCriteria(new Criterion("performance", OperatorId.EQUALS, "pass"));
                      hilite.setCssText("background-color:green;");
                      hilite.setId("0");


                      ListGridField[] dbfield = new ListGridField[dbstr.length];

                      for (int f=0; f<dbstr.length; f++)
                      {
                      dbfield[f]=new ListGridField(dbstr[f]);
                      dbfield[f].setShowHover(true);
                      }
                      //dbfield[7].setAttribute("_hilite", 0);
                      //dbfield[7].setAttribute("_hilite", 1);
                      dblgrid.setFields(dbfield);
                      //dblgrid.setRecords(dbrecord);
                      dblgrid.setHoverWidth(300);
                      dblgrid.groupBy("product", "oem");
                      dblgrid.setDataSource(dsdb);
                      dblgrid.enableHilite("0");





                      <response>

                      <status>0</status>

                      <startRow>0</startRow>

                      <endRow>8</endRow>

                      <totalRows>9</totalRows>
                      <data>
                      <record>
                      <id>1</id>
                      <product>11</product>
                      <performance>pass</performance>
                      </record>
                      <record>
                      <id>2</id>
                      <product>12</product>
                      <performance>pass</performance>
                      </record>
                      <record>
                      <id>3</id>
                      <product>13</product>
                      <performance>pass</performance>
                      </record>

                      </data>

                      </response>


                      thanks

                      Comment


                        #12
                        You're grouping by a field that doesn't exist in the grid or data ("oem").

                        Does it work if you remove this?

                        Does it work if you remove grouping entirely?

                        Comment


                          #13
                          no no that was another field...i deleted that field to make the coding simple for the post...that is no problem...i have that field and grouping is working fine i have this hiliting problem

                          could you help me in that....thanks in advance

                          Comment


                            #14
                            ListGrid dblgrid = new ListGrid();
                            dblgrid.setSize("100%","100%");
                            dblgrid.setAutoFitData(Autofit.BOTH);
                            dblgrid.setCanEdit(false);
                            dblgrid.setCanSort(false);
                            dblgrid.setAutoFetchData(true);
                            dblgrid.setShowFilterEditor(true);
                            dblgrid.setGroupStartOpen(GroupStartOpen.ALL);
                            dblgrid.setCanGroupBy(false);
                            dblgrid.setCanPickFields(false);

                            String[] dbstr = new String[]{"id", "product", "performance"};

                            RestDataSource dsdb = new RestDataSource();
                            DataSourceField[] dsfield = new DataSourceField[dbstr.length];
                            for (int d = 0; d<dbstr.length; d++)
                            {
                            dsfield[d]=new DataSourceField(dbstr[d],FieldType.TEXT);
                            }
                            dsfield[0].setPrimaryKey(true);
                            dsdb.setFields(dsfield);
                            dsdb.setDataFormat(DSDataFormat.XML);

                            OperationBinding fetchd=new OperationBinding();
                            fetchd.setOperationType(DSOperationType.FETCH);
                            fetchd.setDataProtocol(DSProtocol.GETPARAMS);

                            dsdb.setOperationBindings(fetchd);

                            dsdb.setFetchDataURL("/sampledb.xml");

                            Hilite hilite = new Hilite();
                            hilite.setCriteria(new Criterion("performance", OperatorId.EQUALS, "pass"));
                            hilite.setCssText("background-color:green;");
                            hilite.setId("0");


                            ListGridField[] dbfield = new ListGridField[dbstr.length];

                            for (int f=0; f<dbstr.length; f++)
                            {
                            dbfield[f]=new ListGridField(dbstr[f]);
                            dbfield[f].setShowHover(true);
                            }
                            dblgrid.setFields(dbfield);
                            dblgrid.setHoverWidth(300);
                            dblgrid.groupBy("product");
                            dblgrid.setDataSource(dsdb);
                            dblgrid.enableHilite("0");





                            <response>

                            <status>0</status>

                            <startRow>0</startRow>

                            <endRow>2</endRow>

                            <totalRows>3</totalRows>
                            <data>
                            <record>
                            <id>1</id>
                            <product>11</product>
                            <performance>pass</performance>
                            </record>
                            <record>
                            <id>2</id>
                            <product>12</product>
                            <performance>pass</performance>
                            </record>
                            <record>
                            <id>3</id>
                            <product>13</product>
                            <performance>pass</performance>
                            </record>

                            </data>

                            </response>



                            Here is the updated one....this is what i am doing...and trying to hilite the cell...but it is not working...is there any thing else that i need to do for example some kind of setting or css file change or something......thanks in advance

                            Comment


                              #15
                              Whoops, very obvious problem: no call to setHilites() at all. The ListGrid has no knowledge of your hilite definition.

                              Comment

                              Working...
                              X