W
W
Wladimir742017-02-16 19:13:31
JavaScript
Wladimir74, 2017-02-16 19:13:31

JqGrid and select field?

Good afternoon,
I started learning Jqgrid, everything is fine, but I got stuck with this.
One of the fields in colmodel needs to be assigned the "select" type. With data loaded from the database. The field becomes the desired type, but the data is not loaded into it. At first, I sinned on the wrong file format that takes data from the database and gives it to the field. Registered in "editoption" the data in the form of a line. Same result - select is empty. I am sure that the problem is in the little things, but I can’t understand in any way what.
I will be immensely glad for your help. Thank you.
Here is my jqgrid:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=cp1251" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Kor10</title>
 
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-cupertino/jquery-ui.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<style>
html, body {
    margin: 0;
    padding: 0;
    font-size: 75%;
}
</style>
 
<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jqDnR.js"></script>
<script type="text/javascript" src="js/grid.common.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
 
</head>
<body>
<table id="ndvjmst"><tr><td></td></tr></table> 
<div id="pager_nd"></div> 
<script type="text/javascript">
$(function () {
  var lastSelection;
    $("#ndvjmst").jqGrid({
        url:'nd_get.php',
        datatype: "xml",
        mtype: "POST",
        colNames: ["id", "Номер", "Тип недвижимости","Право владения","Площадь"],
        colModel: [
            { name: "id", width: 55},
            { name: "nomer", width: 250, editable: true},
            { name: "type", index:"type", width: 200, editable: true, formatter: "select", edittype:"select",editoption: { value: "1:Квартира; 2:Офис; 3:машино-место" }},
      { name: "pravo",  width: 80, editable: true},
      { name: "plohad", width: 150, align: "right",editable: true},
        ],
        pager: "#pager_nd",
        rowNum: 10,
        rowList: [10, 20, 30],
        sortname: "id",
        sortorder: "desc",
        viewrecords: true,
        gridview: true,
        autoencode: true,
    editurl:'nd_set.php',
        caption: "Недвижимость - Кор10",
            onCellSelect: function (rowid, iCol, cellContent, e) {
                        $("#ndvjmst").restoreRow(lastSelection);
                        $("#ndvjmst").editRow(rowid, true, null, null, null, null, null);
                        lastSelection = rowid;  
                      }
    }); 

    $('#ndvjmst').navGrid('#pager_nd',

        {
        edit: true,
        add: true,
        del: true,
        search: false,
        refresh: false,
        view: false,
        position: "left",
        cloneToTop: false
        },

        {
        editCaption: "The Edit Dialog",
        recreateForm: true,
        checkOnUpdate: true,
        checkOnSubmit: true,
        closeAfterEdit: true,
        errorTextFormat: function(data) {
          return 'Error: ' + data.responseText
        }

        },
        // options for the Add Dialog
        {
        closeAfterAdd: true,
        recreateForm: true,
        errorTextFormat: function(data) {
          return 'Error: ' + data.responseText
        }
        },
        // options for the Delete Dailog
        {
        errorTextFormat: function(data) {
          return 'Error: ' + data.responseText
        }
        });
}); 
</script>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-06-29
@dtmse

Most likely, the answer has a purely historical value, but ... In general, instead of writing
editoption: { value: "1:Квартира;
editoptions: { value: "1:Квартира;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question