Results 1 to 6 of 6

Thread: TreeNode edit call to server help

  1. #1

    Default TreeNode edit call to server help

    Hi,

    i am playing around wit the dependency.js example with the tree nodes, and i really like the edit function where you can click the component and it converts to a text field which can be edited. I was wondering if there is a callback for the edit so when an edit occurs, you can send data to the server, check something, and either allow the edit to occur on the server and client or not.

    Below is the code i am referring to:

    Code:
    var node = new xt.TreeNode({
                text: text,
                iconCls:'cmp',
                cls:'cmp',
                type:'cmp',
                id: id,
                cmpId:id,
                allowDelete:true,
                allowEdit:true,
                qtip:'Message will go here'
               
            });
    I tired:

    beforecomplete: callBack

    but that does not seem to t work. Any help would be greatly appreciated. I tired looking up the documentation, but i was not able to find anything. I cannot even find "allowEdit" config option in the documentation either....

    thanks!

  2. #2

    Default

    The following code did the trick:

    Code:
    var ge = new xt.TreeEditor(ctree, {
                        allowBlank:false,
                        blankText:'A name is required',
                        selectOnFocus:true,
                        cancelOnEsc: true,
                        completeOnEnter: true
                    });
    
                    ge.on('beforestartedit', function(){
                        if(!ge.editNode.attributes.allowEdit){
                            return false;
                        }
                    });
    
                    //inline message group name editing - ajax enabled
                    ge.on('beforecomplete', function(editor, value, startValue){
                        var id = sm.getSelectedNode().id;
                        
                        var wasSuccess = true;
                        var node = croot.findChild('text',value);
    
                        if ((node != null) && (node.text != startValue)){
                            showExtModalAlert('Error Updating Group Name', 'Another group with that name already exists, please try again.');
                            wasSuccess = false;
                        }
                        else if (value.length > 40){
                            showExtModalAlert('Error Updating Group Name', 'The group name length cannot exceed 40 characters, please try again.');
                            wasSuccess = false;
                        }
                        else if (value != startValue){
                            var content = "doAsRemoteCall=true&messageGroupName=" + value + "&action=editMessageGroupName&id=" + id + "&queueId=" + queueId;
                            doExtAjaxCall("queueCannedMessage.do", content, null);
                        }
    
                        return wasSuccess;
                    });
    The "beforecomplete" event is key. Returning true or false from the event handler will cause the value to change or revert.

  3. #3

    Default

    I know this post is old, but I tried exactly what was posted and it does NOT revert back to the orig value AND it does not cancel the edit box.

    Is there any developer around to explain why? I've also put another post in about this. I've tried everything.

  4. #4
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    Just handle that behaviour yourself:
    Code:
      editor.on('beforecomplete', function(editor, value, startValue){
                        if(spellsTrouble(value)){
                             
                               editor.cancelEdit(true);
                               if(editor.updateEl && editor.boundEl){
                                       editor.boundEl.update(startValue);
                               }
                               editor.hide();
                               editor.editing = false;
                              return false;
                       }
         });
    or, assign the TextField a custom validator and let it handle the rest:
    Code:
    var ge = new xt.TreeEditor(ctree, {
                        allowBlank:false,
                        blankText:'A name is required',
                        selectOnFocus:true,
                        cancelOnEsc: true,
                        completeOnEnter: true,
                        validator:function(value){
                                return isOK(value) || 'Your Node input is invalid'; //true or error message
                        }
                    });
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  5. #5
    Ext User hunkybill's Avatar
    Join Date
    Mar 2007
    Location
    Montreal
    Posts
    67

    Default

    Quote Originally Posted by hendricd View Post
    Just handle that behaviour yourself:
    Code:
      editor.on('beforecomplete', function(editor, value, startValue){
                        if(spellsTrouble(value)){
                             
                               editor.cancelEdit(true);
                               if(editor.updateEl && editor.boundEl){
                                       editor.boundEl.update(startValue);
                               }
                               editor.hide();
                               editor.editing = false;
                              return false;
                       }
         });
    I do this and get a blowout on too much recursion...??

    var args = Array.prototype.slice.call(arguments, 0); line 1501 of ext-all-debug.js (Ext.2.0 final)...

    Not sure why cancelling a complete event goes all recursive??

  6. #6

    Default

    This i used this code in version 1.1. I have not tired it in 2.0.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •