1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    3
    Vote Rating
    0
    chapman16046 is on a distinguished road

      0  

    Default using picklist in view to update multiple docs

    using picklist in view to update multiple docs


    HI all,
    is it possible to use the picklist out of button in a view to update multiple documents?

    i want to select multiple docs in a view and choose my nab lookup and update all the docs in the view w/ the single user from the nab lookup.

    this pops the address book from the view;
    var ws = new Ext.nd.UIWorkspace();
    var name=ws.pickList({type: "", dbPath : "/names.nsf/", viewName : "SMTSPeople", title : "Notes Address Book Lookup", prompt : "", column :3, multipleSelection : false, useCheckboxSelection : false});


    Capture.PNG

  2. #2
    Sencha - Services Team
    Join Date
    Mar 2007
    Location
    Foristell, MO
    Posts
    1,108
    Vote Rating
    3
    jratcliff is on a distinguished road

      0  

    Default


    I'll have to review the code but I believe you get an array of values when you click OK in the address book window. You could take that array, along with the UNIDs of the docs selected and do an Ajax post to an agent on your server that will do what you want. If I have some time over the next few days I'll see if I can give more of a code example.
    Jack Ratcliff
    Sencha Inc, Green bleeding Senchan

    How to report a bug:
    http://www.sencha.com/forum/showthre...o-report-a-bug

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Posts
    3
    Vote Rating
    0
    chapman16046 is on a distinguished road

      0  

    Default Or Window.open

    Or Window.open


    Thanks jack...I also tried using this technique: calling the ajax nab picker w/ the window.open...its able to pop the dialog box, but I still can't pass the return value over to my action button, then the js script to update the documents in the view.

    the call from the button:
    alert("Starting...");
    var returnField = "OWNERCOMIT_ID";
    var specialParameters = "&db=names.nsf" +"&view=SMTSPeople"+ "&columns=1,2,3" + "&returncol=3" ;
    var mywin=window.open("NABPickerSingle?Open&returnfield="+returnField +specialParameters, "popupWindow", "toolbar=no,directories=no,status=no,scrollbars=auto,resizable=yes,resize=yes,menubar=no,height=500,width=800");
    handleActOnNAB(returnField, newValue, this);

    then using the task handlerwhich is the same as your handleonTasks demo:
    function handleActOnNAB(field, value, actionbar) {
    var view = actionbar.getUIView();
    var selections = view.getDocuments();

    if (selections.length == 0) {
    Ext.Msg.alert("Sorry", "You must first select one or more documents before you can perform this action.");
    } else {
    Ext.Msg.confirm(
    "Are you sure?",
    "You have selected " + selections.length + " element(s) to change the " + field + " field" + ", are you sure?",
    function(answer) {

    if (answer == 'yes') {
    // build a string of name/value pairs for our value and unids
    var p = "field=" + field + "&value=" + value;
    // loop over selections and add in the unids
    Ext.each(selections, function(item, index, allitems) {
    p += "&unid=" + item.unid;
    });

    // make an ajax post request to our agent
    Ext.Ajax.request({
    method: 'POST',
    url : actionbar.dbPath + 'actOnTasks?openAgent',
    success : handleActOnTasksSuccess,
    failure : handleActOnTasksFailure,
    params : p, // this is our field, value, and unids
    extraParams : {
    field : field,
    value : value
    }, // we can put really anything here, I'm adding field and value so we can get to these values in our callback functions
    scope : actionbar // set scope to actionbar so our callback function runs as if it was running from the actionbar button
    });

    }

    },
    this); // eo Ext.Msg.confirm
    } // eo if/then/else
    }
    Attached Images

  4. #4
    Sencha User
    Join Date
    Apr 2011
    Posts
    3
    Vote Rating
    0
    chapman16046 is on a distinguished road

      0  

    Default Figured it out!

    Figured it out!


    created a shared action and put this in view:

    Code:
    ws = new Ext.nd.UIWorkspace();
    var bar = this;
    ws.pickList({type: "", dbPath : "/names.nsf/", viewName : "SMTSPeople", title : "Address Book Lookup", prompt : "", column :3, multipleSelection : false, useCheckboxSelection : false, callback : handleMyPickList });
    // the return of the PickList will be an array of strings
     function handleMyPickList(arStrings) {
       var tmp = "";
       if (arStrings == null) {
        ws.prompt('OK', '', 'you clicked cancel');
       } else {
        for (var i=0; i<arStrings.length; i++) {
         tmp += arStrings[i] ;
        }
        handleActOnTasks("OWNERCOMIT_ID", tmp, bar);      
       }
      }
    Last edited by jratcliff; 20 Mar 2013 at 6:46 AM. Reason: added [code] tags so the code would be readable

  5. #5
    Sencha - Services Team
    Join Date
    Mar 2007
    Location
    Foristell, MO
    Posts
    1,108
    Vote Rating
    3
    jratcliff is on a distinguished road

      0  

    Default


    Great job! Hopefully with our next version of Extnd we'll make tasks such as these even easier. Glad you figured this out though!

    Quote Originally Posted by chapman16046 View Post
    created a shared action and put this in view:

    Code:
    ws = new Ext.nd.UIWorkspace();
    var bar = this;
    ws.pickList({type: "", dbPath : "/names.nsf/", viewName : "SMTSPeople", title : "Address Book Lookup", prompt : "", column :3, multipleSelection : false, useCheckboxSelection : false, callback : handleMyPickList });
    // the return of the PickList will be an array of strings
     function handleMyPickList(arStrings) {
       var tmp = "";
       if (arStrings == null) {
        ws.prompt('OK', '', 'you clicked cancel');
       } else {
        for (var i=0; i<arStrings.length; i++) {
         tmp += arStrings[i] ;
        }
        handleActOnTasks("OWNERCOMIT_ID", tmp, bar);      
       }
      }
    Jack Ratcliff
    Sencha Inc, Green bleeding Senchan

    How to report a bug:
    http://www.sencha.com/forum/showthre...o-report-a-bug

Thread Participants: 1