• Many bugs with DataGrid(4)

    By Roman V Ivanov 1 decade ago

    1) RestService.revert for DataGrid not working
    Solution:

    restViewItemFileService.revert = function() {

                for(var s in this._pendings) {
                    var p = this._pendings[s]
                                          <b> if(p.op == 1) {</b>
    

    for( var i in p.modAttrs) {
    p.modAttrs[i] = p.oldAttrs[i]
    }
    }

                }
                this.created = 0;
                return true;
            }
    
    
            restViewItemFileService.setValue = function(   /* item */ item, 
                   /* string */ attribute,
                   /* almost anything */ value){
                this._assertIsItem(item);
                this._assertHasAttribute(item, attribute);
                if (typeof value == 'undefined' || value === null)
                    throw new Error("TableStore.setValue: invalid parameter");
    
               // Don't allow changing the item's identity
                if(attribute == this._identity){
                    throw new Error("TableStore does not support changing the value of an item's identifier.");
                }
    
                var id = this.getIdentity(item)
                var pending = this._pendings[id]
                                             if(!pending) {
                                                 pending = {op:1, origAttrs: item.attributes, modAttrs:{}, <b>oldAttrs:{}</b>}
                                                 this._pendings[id] = pending
                                             } else {
                                                 if(pending.op==2) {// Deleted, do nothing
                                                     return false;
                                                 }
                                                // Created or modified, just continue
                                             }
    
                var oldValue = item.attributes[attribute];      
                item.attributes[attribute] = pending.modAttrs[attribute] = value;
                <b>if ( !pending.oldAttrs[attribute] )</b>
    

    pending.oldAttrs[attribute] = oldValue;

                this.onSet(item, attribute, oldValue, value);
                return true;// boolean
            }
    

    2) Encoding for restViewItemService not working
    Solution:

    function fixEncoding() {

    if( !(dojo._xhrPost )) {
        dojo._xhrPost = dojo.xhrPost;
    }
    
    dojo.xhrPost = function (args) {
        if ( args.headers &amp;&amp; ( args.headers["Content-Type"] == "application/json" ) ) {
            args.headers["Content-Type"] = "application/json;charset=UTF-8";
        }
        return dojo._xhrPost(args);
    }
    

    }

    3) Quotes not working in DataGrid
    Sulution:

    function fixQuotes() {

    dojox.grid.cells.Cell.prototype.formatEditing = function(inDatum, inRowIndex)
    {
        this.needFormatNode(inDatum, inRowIndex);
        return '';
    };
    

    }

    4) After Infinity scrolling(DataGrid…) edit mode not working(cannot exiting from edit mode)
    Solution:
    set rowsPerPage = 10000+

    • By Roman V Ivanov 1 decade ago

      Brr.. bad markdown :(

    • By Paul Hannan 1 decade ago

      Thanks Roman, would you have details on the original issues along with the solutions you've posted here?
      And might it help if these solutions were put into a sample app?

      • By Roman V Ivanov 1 decade ago

        Ok. One post - one bug
        restViewItemService.revert not working - Uncaught ReferenceError: op is not defined
        Fix:
        Change code in/xsp/.ibmxspres/.extlib/dojo/data/FileStore.js
        functions:

        revert: function(){
            for(var s in this._pendings) {
                var p = this._pendings[s]</font><font color="#333333" size="2">
                if(p.op == 1) {</font><font color="#333333" size="2">
                    for( var i in p.modAttrs) {</font><font color="#333333" size="2">                    p.modAttrs[i] = p.oldAttrs[i]                }            }        }        this.created = 0;        return true;    },
        
        setValue: function(/* item */ item, 
                       /* string */ attribute,
                       /* almost anything */ value){
            this._assertIsItem(item);
            this._assertHasAttribute(item, attribute);
            if (typeof value == 'undefined' || value === null)
                throw new Error("TableStore.setValue: invalid parameter");
        
           // Don't allow changing the item's identity
            if(attribute == this._identity){
                throw new Error("TableStore does not support changing the value of an item's identifier.");
            }
        
            var id = this.getIdentity(item)
            var pending = this._pendings[id]
            if(!pending) {
                pending = {op:1, origAttrs: item.attributes, modAttrs:{}, oldAttrs:{}}
                this._pendings[id] = pending
            } else {
                if(pending.op==2) {// Deleted, do nothing
                    return false;
                }
               // Created or modified, just continue
            }
        
            var oldValue = item.attributes[attribute];      
            item.attributes[attribute] = pending.modAttrs[attribute] = value;
            if ( !pending.oldAttrs[attribute] )
                pending.oldAttrs[attribute] = oldValue;
            this.onSet(item, attribute, oldValue, value);
            return true;// boolean
        }
        

        Temp solution:
        Add this code in onClientLoad -> dojo.addOnLoad( restServiceID.revert = function(){ ..code.. } )

        • By Paul Hannan 1 decade ago

          Thanks Roman for the clarification. I'm investigating all four issues you've logged and for the revert on xe:restViewItemService I've logged PHAN9FCFQ6 for tracking purposes.

      • By Roman V Ivanov 1 decade ago

        Encoding for restViewItemService not working
        If i save rest service (in FireFox its OK), then headers havent info about encoding


        Temp solution:
        Add in onClientLoad

        dojo.addOnLoad(
            function() {
                if( !(dojo._xhrPost )) {
                    dojo._xhrPost = dojo.xhrPost;
                }
        
                dojo.xhrPost = function (args) {
                    if ( args.headers &amp;amp;&amp;amp; ( args.headers["Content-Type"] == "application/json" ) ) {
                        args.headers["Content-Type"] = "application/json;charset=UTF-8";
                    }
                    return dojo._xhrPost(args);
                }
            }
        )</span></font>
        
        • By Roman V Ivanov 1 decade ago
          &amp;amp;&amp;amp = &&
        • By Paul Hannan 1 decade ago

          Hi Roman, could you clarify the steps you used to reproduce this issue?

          • By Roman V Ivanov 1 decade ago

            use store restViewItemService
            edit cell in datagrid(not in english language), click save

            • By Paul Hannan 1 decade ago

              Sorry Roman. I've not made progress on this one. I'm stuck on where to get restViewItemService?

      • By Roman V Ivanov 1 decade ago

        Quotes not working in DataGrid
        If i edit cell and write quotes(exmpl: qwe"rty ), then after save value modified to qwe
        https://bugs.dojotoolkit.org/ticket/11993

        • By Paul Hannan 1 decade ago

          Hi Roman, I've not been able to reproduce this issue with the quotes. Do you have any more information on how to reproduce this issue?

          • By Roman V Ivanov 1 decade ago

            use store restViewItemService
            edit cell in datagrid, enter 'qwe"qwe', click save

    • By Roman V Ivanov 1 decade ago

      After Infinity scrolling(DataGrid…) edit mode not working(cannot exiting from edit mode)
      http://stackoverflow.com/questions/20771779/xpages-datagrid-not-exiting-from-edit-mode

      Temp solution:
      set rowsPerPage = 10000+

      • By Roman V Ivanov 1 decade ago

        I solved it
        http://stackoverflow.com/questions/20771779/xpages-datagrid-not-exiting-from-edit-mode/21185843#21185843