Announcement

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

    listGrid display boolean integers as integers?

    I'm wondering if there is a way to override the default behavior of listgrids to display 1/0/null integer fields or y/n text fields as "true" and "false". The true/false display is nice, but can lead to confusion when filtering the data. Typing "true" into the filter box at the top of the column does nothing. However typing 1 or 0 and filtering the grid filters the data correctly. In this case I think displaying the raw underlying data will lead to less confusion.

    Thanks
    RP

    Using: SmartClient_v120p_2018-05-23_PowerEdition

    #2
    Not quite following this - you already have the ability, via formatters, to display the underlying value or not do so. You also have the ability to produce whatever criteria you want based on user input (formItem.getCriterion()). So there's nothing in your way..

    However, in terms of the simplest approach, what we would recommend is that if a field is logically a boolean but stored as an integer, then you treat it as a boolean on the client, and handle conversion back and forth in the storage layer. We have a property DataSourceField.sqlStorageStrategy that makes this trivial to do.

    Comment


      #3
      My basic clue shortage is that I've tried a number of values for type and format and always get "true" and "false" displayed.

      The underlying field is a MySQL tinyint.

      name:"passedPrelim",
      width:100,
      type:"number",
      format:"#",

      <field name="passedPrelim" type="integer" columnCode="283a3974d64da46cae74908dc7806f30">
      <validators>
      <Validator>
      <type>isInteger</type>
      <stopIfFalse>true</stopIfFalse>
      <typeCastValidator>true</typeCastValidator>
      </Validator>
      </validators>
      </field>

      examples of failed combos:

      type:"integer",
      format:"#"

      type:"integer",
      format:"0"

      type:"number",
      format:"#"

      type:"number",
      format:"0"

      Comment


        #4
        ??

        None of that is related to what we recommended.. nor is that a valid format string (see FormatString in the docs).. and also if you are seeing true and false then that's probably what you are actually delivering as data, as the framework will not display "true" and "false" unless that's what you provided.

        Comment


          #5
          I guess I didn't understand what you were suggesting. I don't know where to specify the field format other than in the field definition of the grid or in the datasource ds.xml.

          FWIW:
          select distinct passedPrelim from studentData;
          +--------------+
          | passedPrelim |
          +--------------+
          | 1 |
          | NULL |
          | 0 |
          +--------------+
          3 rows in set (0.09 sec)

          So if the data are being delivered to the client as "true" and "false" it's happening in the smartclient server somehow.

          Comment


            #6
            This is a little odd.. there's really quite copious documentation and samples in this area, so we're unsure why you're having trouble.

            You can specify a format on the DataSourceField, it's just that your format is invalid, as we stated. You can also specify formatting functions via ListGridField.formatCellValue.

            It's trivial to find out what you are actually delivering to the browser, either via built-in browser tools or via the Developer Console.

            The framework will not mysteriously turn a 1 or 0 into true or false. You would need to explicitly declare the field as boolean, or define a formatter, to get that result. But as we have already covered, the recommended approach would be to use sqlStorageStrategy. But you ignored that suggestion and seem still focused on using formatting for 0s and 1s. So we're rather baffled here.

            Comment

            Working...
            X