• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Basic checkbox display and update

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Basic checkbox display and update

    I have an application that uses a basic data grid to show some data pulled from a few different tables. As part of a requested update, they want a new column that will allow them to set a basic true/false flag for records in one of the tables. It seems like a labeled column with a checkbox in each row would be a great solution for this but I cannot seem to do this in NAB. The closest I have gotten so far is to use an Edit Grid which displays the rows with the proper column headers but I still have to double click on the row itself before I can then select the checkbox to update the data for a single row. That is going to be extremely tedious when they want to check a lot of rows.

    The other option I've looked into is using the built-in checkboxes on a grid widget when used in an app but I have run into problems there as well. The first is that I can't seem to put a header on that checkbox column. The other is that I can't seem to update the underlying data as soon as they check or uncheck the box. I would also like to be able to move that column next to other columns in the table where it makes more sense but that is less important.

    Is there another solution that I have overlooked?

  • #2
    Maybe this will work for you:
    • Create as edit grid
    • Turn on "cell editing"
    • In the "Edit" section, transform your field to a checkbox

    Comment


    • #3
      To add to Sean's response, you can also set auto-edit via an app variable in the General section. This way, when you're showing the edit grid, you can auto-edit the first row. Then the user can just hit the spacebar to check/uncheck and hit the tab key to move to the next line's checkbox field

      Comment


      • #4
        OK now we are getting somewhere. A couple more things I am finding:

        1) It works pretty well with the spacebar and tab like Johnny suggested but it still takes 3 clicks to set a checkbox when I want to jump around with the mouse. UPDATE: I found the "Single Click Edit" button which brings it down to two clicks to update the field. Not fantastic but I think its acceptable. People are pretty used to double clicking.

        2) It seems to update the data just fine when I check and uncheck the boxes but when I load the data by hitting refresh, it does not show up in the grid even though the field is set. I'm wondering if this is because I'm using the relatively new boolean SQL types? Do you support those yet?

        Comment


        • #5
          What value is the data coming back? What is the value for checked and unchecked?

          Comment


          • #6
            Originally posted by sean.lanktree View Post
            What value is the data coming back? What is the value for checked and unchecked?
            The values for checked and unchecked are true and false respectively.

            Upon initial load, it seems to be returning blanks in the json data structure for that field. I can pull the query out of VVGENLOG and run it through ACS Run SQL Scripts and it returns the correct true and false values on all the records that I updated with the checkboxes though.

            Comment


            • #7
              So no matter what the value in the DB it returns blanks for this field?

              Comment


              • #8
                Originally posted by sean.lanktree View Post
                So no matter what the value in the DB it returns blanks for this field?
                Correct. It is always returning blanks for the boolean field.

                Comment


                • #9
                  Can you show us the DDL definition of the column? For now, maybe you can change your data source to return 1/0 using a case statement.

                  Comment


                  • #10
                    We've tried this on two separate tables. The column definitions are:

                    1) A2_REGION_99_PRODUCT for column A2REG99 boolean not null default false,

                    2) false as SSTCST

                    The second one is created as a table using fields from another table. I added the false as SSTCST to create a boolean field. Both definitions behave the same in Valence though.

                    Also more specifically, it does not return blanks in the JSON. It returns empty strings.

                    As far as casting the value goes, casting to decimal is not supported. IBM chose to implement booleans as a char(1) under the hood so it expects a cast to char(1). That does work to get data returned but it also returns 'T' and 'F'. Unfortunately the Miscellaneous Formatting options for a check mark looks for "Y : y : true :1 : on" but not 'T'.

                    I can't make this work using a case statement as suggested because then it turns the field into Read Only in the Edit Grid.
                    Last edited by Player1st; 07-10-2024, 05:35 PM. Reason: Second edit: I can't make this work with a case statement because it becomes "Read Only"

                    Comment


                    • #11
                      This will be supported in the next update.
                      For now, you can use custom formatting:

                      Code:
                      return (v === 'T') ? '<span class="vvicon-in-cell vvicon-checkmark"></span>' : '';

                      Comment


                      • #12
                        Originally posted by sean.lanktree View Post
                        This will be supported in the next update.
                        For now, you can use custom formatting:

                        Code:
                        return (v === 'T') ? '<span class="vvicon-in-cell vvicon-checkmark"></span>' : '';
                        I swear I tried it yesterday but now I can't even do the edit when I cast it as well. That's OK though. I think can wait for the next Valence update to finish this. It's not time critical.

                        Comment

                        Working...
                        X