• 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.

EmptyCellText not working

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

  • EmptyCellText not working

    I have 2 dates in a grid, read from a DB2 database, which may be null.

    I put 'n/a' in the emptyCellText, but a null date still display '12/31/0000' if the column type is date and '0000/01/01' if the format is text.

    Why isn't n/a showing?

    Thanks for any help.
    Bob Mutascio

  • #2
    When you say that your dates may be "null" coming from the back-end...do you mean "0001-01-01"? If so, javascript would not interpret this as null as it is truly expecting a value of null.

    If this is the case, I would suggest the following:

    Code:
    dataIndex : 'myField',
    text          : 'Some Date',
    renderer   : function(v){
        if (v === '0001-01-01'){
            return 'N/A';
        } else {
            return v;
        }

    Comment


    • #3
      Just thought of another approach you could take as well (assuming the dates are coming in as "0001-01-01"). You can place a convert function where you define your fields:

      Code:
      fields : ['customerNumber','customerName',{
          name : 'myDate',
          convert : function(v){
              if (v === '0001-01-01'){
                  return null;
              } else {
                  return v;
              }
          }
      ]
      After this, you should be able to use your "emptyCellText" method.

      Comment


      • #4
        Originally posted by sean.lanktree View Post
        Just thought of another approach you could take as well (assuming the dates are coming in as "0001-01-01"). You can place a convert function where you define your fields:

        Code:
        fields : ['customerNumber','customerName',{
            name : 'myDate',
            convert : function(v){
                if (v === '0001-01-01'){
                    return null;
                } else {
                    return v;
                }
            }
        ]
        After this, you should be able to use your "emptyCellText" method.
        This solution worked, sort of.

        The actual data field in the DB2 database reports the field as null value.

        But it must somehow be translating the null into '0001-01-01' because when I used the above function, it returned a blank field in the grid. Which is fine. I can live with this result. But that still begs the question, why isn't the EmptyCellText replacing the null value that I'm now explicitly returning with (none)? Is this a bug or am I missing something about how to use this filter?

        BTW, I'm using Architect 3.1.0.1943 and ExtJS 4.2.x.

        Comment


        • #5
          I believe the answer to your question is that a null date on the IBM i that is run through, say, vvOut_execSQLtoJSON, will be converted to 0001-01-01 before being passed on to the browser. So that's what the renderer or convert function would see.

          Comment

          Working...
          X