javascriptfree-jqgrid

Using jQgrid How to Programmatically Select an Element in a Select List


I want to display the Edit form with an element already selected(highlighted) in a dropdown list. The list is populated using AJAX with one of the options set to selected.

If I inspect the process the correct option is set in the BeforeShowForm and AfterShowForm but then reverts back to the empty default value.

colNames:['Index','File Name'],
    colModel:[
        {name:'id', index:'id', width:100, hidden: true, editable: true, editrules:{edithidden:true}, formoptions:{rowpos:1, colpos:1,label:"Index:"}},
        {name:'filename', index:'filename', width:400, hidden: false, editable: true, editrules:{edithidden:true}, formoptions:{rowpos:8, colpos:1,label:"Template Name:"} , edittype: "select", editoptions: { size: 1}},


    ],....

function oSelect(id,status,e){
        $("#aclCushionPlacardlistV8").setColProp('filename', { editoptions: { dataUrl: '/QMSWebApp/AssyComponentListV8SupportControllerServlet?lifecycle=cushionplacardtypeoptions'}});     

    }

    function bsForm(formId){

    }
    function asForm(formId){
    alert("Stop - The desired list element is seleced in the list");
    }

No error messages and list is populated correctly. I just cannot get the programmatic selected portion to work. In the code I show an alert and up to this point all is working. However, when the alert is closed the select list defaults back to the top element 0.


Solution

  • Set the option values to numeric and the programmatic selection works.