You must Sign In to post a response.
  • Category: JavaScript

    Jqgrid dropdown not loading dynamically.once put alert its load the dropdown

    Hi im using jqgrid in my project .

    in inline edit jqgrid not loading the dropdown vlaues dynamically.

    once i put the alert it will load correctly otherwise it doesnt load. kindly help

    and my code is here..............



    function createGrid1(myData1) {

    var data = {
    "rows": eval(myData1)
    };
    jQuery("#jQGridDemo").jqGrid("GridUnload");
    var grid = jQuery("#jQGridDemo"), prmSearch = { multipleSearch: true, overlay: false };
    grid.jqGrid({
    datastr: data,
    datatype: "jsonstring",
    jsonReader: { repeatitems: false },
    colNames: ['DocumentType', 'DocumentDate', 'Amount', 'Action'],
    colModel: [
    { name: 'DocumentType', index: 'DocumentType', width: 30, key: true, editable: true, edittype: "select",
    editoptions: { value: getDocumentType(),
    dataEvents: [{ type: 'keydown', fn: function (e) { EnterTab(e); } }]
    }
    },

    { name: 'DocumentDate', index: 'DocumentDate', width: 20, align: "left", sortable: true, editable: true,
    editoptions: { class: 'date', maxlength: 10,
    dataEvents: [{ type: 'focus', fn: function (e) { dtfocus(this); } },
    { type: 'keydown', fn: function (e) { return myKeyDown(this, e); } },
    { type: 'keydown', fn: function (e) { EnterTab(e); } }]
    }
    },
    { name: 'Amount', index: 'Amount', width: 20, align: "right", sortable: true, editable: true,
    editoptions: { class: 'moneyfc',
    dataEvents: [{ type: 'focus', fn: function (e) { moneyfocus(this); } },
    { type: 'keypress', fn: function (e) { return blockNonNumbers(this, e, true, true); } },
    { type: 'keyup', fn: function (e) { extractNumber(this, 2, true); } },
    { type: 'blur', fn: function (e) { extractNumber(this, 2, true); blockInvalid(this); } },
    { type: 'keydown', fn: function (e) { EnterTab(e); } }]
    }
    },
    { name: 'Action', index: 'Action', width: 20, align: "right", sortable: true, editable: true, editoptions: {
    dataInit: function (elem) { $(elem).focus(function () { this.select(); }) },
    dataEvents: [
    {
    type: 'keydown',
    fn: function (e) {
    var key = e.charCode || e.keyCode;
    if (key == 13) {
    AddNewRow();
    }
    }
    }
    ]
    }
    }
    ],
    onSelectRow: function (id) {
    if (id && id !== lastsel) {
    jQuery('#jQGridDemo').restoreRow(lastsel);
    jQuery('#jQGridDemo').editRow(id, true);
    lastsel = id;
    }
    },
    rownumbers: true,
    'cellEdit': true,
    width: 600,
    height: 100,
    caption: "Inward Register",
    editurl: 'url',
    cellsubmit: 'clientArray',
    pager: '#jQGridDemoPager'
    });
    }




    function getDocumentType() {
    var DocumentTypeList = "";
    var input = {};
    $.ajax({
    type: "POST",
    url: "Service.svc/getDocumentType",
    data: JSON.stringify(input),
    contentType: 'application/json; charset=utf-8',
    dataType: "json",
    success: function (transport) {
    var result = transport.d;
    var obj = JSON.parse(result);
    if (obj != undefined && obj.length > 0) {
    for (var i = 0; i < obj.length; i += 1) {
    if (i == obj.length - 1) {
    DocumentTypeList += "" + obj[i].Data + ":" + obj[i].Display + "";
    }
    else {
    DocumentTypeList += "" + obj[i].Data + ":" + obj[i].Display + ";";
    }
    }
    }
    }
    });
    alert(DocumentTypeList);
    return DocumentTypeList;
    }




    in the above code when i put alert of documenttypelist the jqgrid dropdown loaded . if i comment that dropdown not loaded
    kindly help
  • #763674
    Hai Prakash,
    The problem looks like before loading of the whole page, the data comes first and drop-down is not getting loaded. Due to that you are not able to see the data in the drop-down.
    As when you keep the break point, it takes some time the load the page and then loads the drop-down with the data.
    So you need to modify your code of filling the data so that when the document is ready, it should fill the drop-down list.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #765050
    thx pawan


  • Sign In to post your comments