Announcement

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

    Listgrid setSelectedRecord

    I have the strangest bug that happens on certain occasions. The problem is that when I set selection on the listgrid, it loses the selection. I tried debugging it and it looks like the grid is not keeping the selection. This only consistently happens when I have grouping in my table and it only happens after I refresh the page. I have so far been unable to reproduce with a standalone testcase. I've also overriden selectRecord and deselectRecord for debugging to make sure it is not being called elsewhere besides the code below.

    I've attached a screenshot of the debug in IE. The attached screenshot is on breakpoint after object.selectRecord() call

    The following code is where I select the record - this has to be done because of server call when selection is changed. We keep the initial primary key and send to the server, server does updates and returns with either the same primary or a different one (in this simple test case, nothing about the table is changed therefore I expect the same selection to be visible). Before I call selectRecord, I make sure to clear all selection first in case the selection coming from the server is different.

    Code:
    deselecting record:
    
        if(object!=null && object.data!=null){
          object.deselectAllRecords();
        }
    
    selecting record:
    
    if(object!=null && object.data!=null){
        var currentData = null;
        if(object.originalData!=null && object.originalData.findByKey!=null){
          currentData = object.originalData;
        }else{
          currentData = object.data;
        }
        var record = currentData.findByKey(pk);
          
        if(record!=null){
          object.selectRecord(record);
        }
    
      }
    Another thing to note is when data is initially loaded, I get the following error in the JS Console:

    findByKeys: passed record does not have a value for key field 'cwPK__'

    When I debugged this message, I found that it was being shown for the same listgrid I am having problems with. But as you can see in the data, all the row data have cwPK values.


    data from RPC log:

    Code:
    [
        {
            endRow:10, 
            queueStatus:0, 
            totalRows:10, 
            isDSResponse:true, 
            invalidateCache:false, 
            status:0, 
            startRow:0, 
            data:[
                {
                    cwPK__:"14110008", 
                    $isCwSelected:false, 
                    orderNumber:"8914216", 
                    orderVersion:0, 
                    custName:"", 
                    orderType:"NEW", 
                    suppType:"", 
                    getDate:"07-14-2011", 
                    curEditor:"User Profile Administrator", 
                    milestone:"InProgress", 
                    milestoneStatus:"", 
                    displayStatus:"InProgress", 
                    solution:"Business Line", 
                    services:"Business Line", 
                    iADCaseNum:""
                }, 
                {
                    cwPK__:"14110007", 
                    $isCwSelected:false, 
                    orderNumber:"8914181", 
                    orderVersion:0, 
                    custName:"", 
                    orderType:"NEW", 
                    suppType:"", 
                    getDate:"07-14-2011", 
                    curEditor:"User Profile Administrator", 
                    milestone:"InProgress", 
                    milestoneStatus:"", 
                    displayStatus:"InProgress", 
                    solution:"Calling Card", 
                    services:"Calling Card", 
                    iADCaseNum:""
                }, 
                {
                    cwPK__:"14110006", 
                    $isCwSelected:false, 
                    orderNumber:"8914146", 
                    orderVersion:0, 
                    custName:"", 
                    orderType:"ADD", 
                    suppType:"", 
                    getDate:"07-14-2011", 
                    curEditor:"User Profile Administrator", 
                    milestone:"InProgress", 
                    milestoneStatus:"", 
                    displayStatus:"InProgress", 
                    solution:"Calling Card", 
                    services:"Calling Card", 
                    iADCaseNum:""
                }, 
                {
                    cwPK__:"14110005", 
                    $isCwSelected:false, 
                    orderNumber:"8914124", 
                    orderVersion:0, 
                    custName:"", 
                    orderType:"NEW", 
                    suppType:"", 
                    getDate:"07-14-2011", 
                    curEditor:"User Profile Administrator", 
                    milestone:"InProgress", 
                    milestoneStatus:"", 
                    displayStatus:"InProgress", 
                    solution:"", 
                    services:"", 
                    iADCaseNum:""
                }, 
                {
                    cwPK__:"14110004", 
                    $isCwSelected:true, 
                    orderNumber:"8914102", 
                    orderVersion:0, 
                    custName:"", 
                    orderType:"CHG", 
                    suppType:"", 
                    getDate:"07-14-2011", 
                    curEditor:"User Profile Administrator", 
                    milestone:"InProgress", 
                    milestoneStatus:"", 
                    displayStatus:"InProgress", 
                    solution:"", 
                    services:"", 
                    iADCaseNum:""
                }, 
                {
                    cwPK__:"14110003", 
                    $isCwSelected:false, 
                    orderNumber:"8914068", 
                    orderVersion:0, 
                    custName:"", 
                    orderType:"CHG", 
                    suppType:"", 
                    getDate:"07-14-2011", 
                    curEditor:"User Profile Administrator", 
                    milestone:"InProgress", 
                    milestoneStatus:"", 
                    displayStatus:"InProgress", 
                    solution:"Business Line", 
                    services:"Business Line", 
                    iADCaseNum:""
                }, 
                {
                    cwPK__:"14110002", 
                    $isCwSelected:false, 
                    orderNumber:"8914034", 
                    orderVersion:0, 
                    custName:"", 
                    orderType:"CHG", 
                    suppType:"", 
                    getDate:"07-14-2011", 
                    curEditor:"User Profile Administrator", 
                    milestone:"InProgress", 
                    milestoneStatus:"", 
                    displayStatus:"InProgress", 
                    solution:"Business Line", 
                    services:"Business Line", 
                    iADCaseNum:""
                }, 
                {
                    cwPK__:"14110001", 
                    $isCwSelected:false, 
                    orderNumber:"8914000", 
                    orderVersion:0, 
                    custName:"", 
                    orderType:"CHG", 
                    suppType:"", 
                    getDate:"07-14-2011", 
                    curEditor:"User Profile Administrator", 
                    milestone:"InProgress", 
                    milestoneStatus:"", 
                    displayStatus:"InProgress", 
                    solution:"Business Line", 
                    services:"Business Line", 
                    iADCaseNum:""
                }, 
                {
                    cwPK__:"14100005", 
                    $isCwSelected:false, 
                    orderNumber:"8913170", 
                    orderVersion:0, 
                    custName:"", 
                    orderType:"NEW", 
                    suppType:"", 
                    getDate:"07-14-2011", 
                    curEditor:"User Profile Administrator", 
                    milestone:"InProgress", 
                    milestoneStatus:"", 
                    displayStatus:"InProgress", 
                    solution:"", 
                    services:"", 
                    iADCaseNum:""
                }, 
                {
                    cwPK__:"14100004", 
                    $isCwSelected:false, 
                    orderNumber:"8913170", 
                    orderVersion:0, 
                    custName:"", 
                    orderType:"NEW", 
                    suppType:"", 
                    getDate:"07-14-2011", 
                    curEditor:"User Profile Administrator", 
                    milestone:"InProgress", 
                    milestoneStatus:"", 
                    displayStatus:"InProgress", 
                    solution:"Business Line", 
                    services:"Business Line", 
                    iADCaseNum:""
                }
            ]
        }
    ]
    Attached Files

    #2
    It's not valid to change primary key on an update - you must use an "remove" than an "add" operation to do this. Attempting to change the primary key could certainly lead to odd warnings - it's not clear how these particular consequences arise, but you need to fix how you're changing keys regardless.

    Comment


      #3
      Where do you see the changing of the primary keys? I am not aware of this being done anywhere...as far as I know, our primary key for all listgrids is cwPk__

      Comment


        #4
        Is this not what you said: "We keep the initial primary key and send to the server, server does updates and returns with either the same primary or a different one?"

        The value for a record's primary key must not change.

        Comment


          #5
          I debugged again at that point that I am getting an error - _1 is a number, not a record so I am not sure why it would try to get cwPk__ from that . I attached the debug screens
          Attached Files

          Comment


            #6
            As I mentioned in the previous post, nothing about the listgrid is changed. We only keep track of the primarykey in order to reselect the record later. Sorry for any misunderstanding - by "server does updates" I was referring to other parts of the UI such as enabling/disabling of buttons. And when I say "either the same primary or a different one" I mean the server can come back with a different primary key as a way to select another row instead of the original selection. But this primary key is already part of the data that is shown on the listgrid. NOTHING changes in the data.


            Originally posted by davidj6
            Is this not what you said: "We keep the initial primary key and send to the server, server does updates and returns with either the same primary or a different one?"

            The value for a record's primary key must not change.
            Last edited by acarur01; 19 Jul 2011, 05:26.

            Comment


              #7
              Here's another screenshot of that breakpoint but this time with no grouping in the listgrid. You can see the difference
              Attached Files

              Comment


                #8
                There's not a lot we can do with this. We agree that, with the information you've shared and the statements you made about the behavior, this is clearly impossible. Since it's happening, something else you haven't talked about is clearly also going on :)

                At a guess, some other application code is either modifying or replacing the dataset during the processing of the server's response.

                Comment


                  #9
                  I don't know what else I can provide you except a stripdown code of what the listgrid. Clearly, there is a change in behaviour between this listgrid having a group and when it does not. It works perfectly fine as soon as I remove the grouping - with no other changes in our product.


                  Code:
                  isc.DataSource.create({ID:"myOrderswrklstFinderResultTable$ds",
                  fields:
                  [{name:"cwPK__",primaryKey:true},
                  {name:"orderNumber"},
                  {name:"orderVersion1"},
                  {name:"custName"},
                  {name:"orderType"},
                  {name:"suppType"},
                  {name:"getDate"},
                  {name:"curEditor"},
                  {name:"milestone"},
                  {name:"milestoneStatus"},
                  {name:"displayStatus"},
                  {name:"solution"},
                  {name:"services"},
                  {name:"iADCaseNum"}
                  ]});
                  
                  isc.ListGrid.create({fastCellUpdates:false,hiddenFields:
                  ["milestone","milestoneStatus"],
                  groupByField:["custName"],dataSource:"myOrderswrklstFinderResultTable$ds",
                  dataProperties:{useClientFiltering:false,neverDropUpdatedRows:true},
                  ID:"myOrderswrklstFinderResultTable",
                  modalEditing:true,
                  canSelectText:true,
                  selectOnEdit:true,
                  autoFetchData:false,
                  canSort:true,
                  fields:
                  [{title:"<nobr>UNO SO #&nbsp;<\/nobr>",editorType:"text",name:"orderNumber",align:"left",validateOnChange:true,width:"10%"},
                  {title:"<nobr>Order Version&nbsp;<\/nobr>",editorType:"text",type:"decimal",name:"orderVersion",align:"left",validateOnChange:true,width:"10%"},
                  {title:"<nobr>Customer Name&nbsp;<\/nobr>",editorType:"text",name:"custName",align:"left",validateOnChange:true,width:"16%"},
                  {title:"<nobr>Request Type&nbsp;<\/nobr>",editorType:"text",name:"orderType",align:"left",validateOnChange:true,width:"8%"},
                  {title:"<nobr>Sub Type&nbsp;<\/nobr>",name:"suppType",align:"left",validateOnChange:true,width:"8%"},
                  {title:"<nobr>Action Date&nbsp;<\/nobr>",editorType:"text",name:"getDate",align:"left",canEdit:false,validateOnChange:true,width:"11%"},
                  {title:"<nobr>Assigned By&nbsp;<\/nobr>",editorType:"text",name:"curEditor",align:"left",validateOnChange:true,width:"11%"},
                  {title:"<nobr>Milestone&nbsp;<\/nobr>",editorType:"text",name:"milestone",align:"left",showIf:"return false",validateOnChange:true,width:"11%"},
                  {title:"<nobr>Status&nbsp;<\/nobr>",editorType:"text",name:"milestoneStatus",align:"left",showIf:"return false",validateOnChange:true,width:"11%"},
                  {title:"<nobr>Status&nbsp;<\/nobr>",editorType:"text",name:"displayStatus",align:"left",validateOnChange:true,width:"20%"},
                  {title:"<nobr>Solution&nbsp;<\/nobr>",editorType:"text",name:"solution",align:"left",validateOnChange:true,width:"11%"},
                  {title:"<nobr>Services&nbsp;<\/nobr>",editorType:"text",name:"services",align:"left",validateOnChange:true,width:"11%"},
                  {title:"<nobr>iADCaseNum&nbsp;<\/nobr>",editorType:"text",name:"iADCaseNum",align:"left",validateOnChange:true,width:"100"}]
                  });

                  Comment


                    #10
                    Yes - *in your environment* there is such a difference. Until we have something we can run, all we can do is jointly speculate as to causes, and we're out of speculations.

                    Comment


                      #11
                      Where else can I debug to see this as a possibility? Where can I put a breakpoint in the code?

                      "At a guess, some other application code is either modifying or replacing the dataset during the processing of the server's response."

                      Comment


                        #12
                        Remember, we don't have your code, so we can't really suggest where to put a breakpoint in your code.

                        Sorry we can't be of further help, but please bear in mind what you've given us to work with:

                        1. we have no way of reproducing the problem
                        2. we've already inspected the framework code, and, given what you've told us, there's no way for this to happen

                        The solution is somewhere in code we don't have.

                        Comment


                          #13
                          I meant where in SmartClient code I could check using IE JS debugger - I didn't mean in our code (that's just silly).

                          Anyway, I don't know what the difference is but it seems to have something to do with deselectAllRecords() - I've changed this to gather all the selected records and deselect one by one and now I cannot reproduce my problem. Timing issue possibly? I don't know. But it works now.

                          Comment


                            #14
                            All selection-related methods are synchronous so it can't really be a timing issue (at least in framework code). If you see something that suggests there might a SmartClient bug, please let us know.

                            Comment

                            Working...
                            X