Forum


16:45

07/10/2014

Hi,
    I have a jq grid,in that one column is a dropdown cloumn where we can select some thing and just click on enter it will update only two options available one is true and another is false
If user selects false form dropdown the entire row on the spot has to change in red color..but the problem is once i update to false after clicking on refresh color is reflecting..
Â
This is my code..will any one tell me what needs to do.I am calling color logic in grid complete
Â
        $(function() {
            var lastSelectedId;
           var rowsToColor = [];
            $("#list").jqGrid({
                url: 'sample.ashx',
                datatype: 'json',
                height: 250,
                colNames: ['Name', 'ID', 'Desc', 'Date'],
                colModel: [
                     { name: 'Name', index: 'Name', width: 256, stype: 'text', editable: true, sortable: false, editoptions: { disabled: "disabled"} },
                     { name: 'ID', index: 'ID', width: 256, stype: 'text', editable: true, sortable: false, editoptions: { disabled: "disabled"} },
                     { name: 'Desc', index: 'Desc', width: 256, stype: 'text', sortable: false, editable: true, edittype: 'select', editoptions: { readonly: true },
                          formatter: rowColorFormatter,
                         editoptions: { value: "true:true; false:false" }
                     },
                     { name: 'Date', index: 'Date', width: 256, editable: true, stype: 'text', sortable: true, sorttype: 'date', editoptions: { disabled: "disabled"} }
                          ],
                rowNum: 10,
                loadonce: true,
                rowList: [10, 20, 30],
                pager: '#pager',
                sortname: 'name',
                viewrecords: true,
                sortorder: 'asc',
                gridview: true,
                ignoreCase: true,
                caseSensitive: false,
                rownumbers: true,
                reloadAfterSubmit: false,
                width: 1024,
                gridComplete: function() {
                    for (var i = 0; i < rowsToColor.length; i++) {
                        var EventDesc = $("#" + rowsToColor[i]).find("td").eq(3).html();
                        if (EventDesc == "unavailable") {
                            $("#" + rowsToColor[i]).find("td").css("background-color", "#FF4D4D");
                        }
                    }
                },
                jsonReader: {
                    repeatitems: false
                },
                caption: 'Caption',
                editurl: 'sampler.ashx',
                onSelectRow: function(id) {
   Â
                    if (id && id !== lastSelectedId) {
                        $('#list').restoreRow(lastSelectedId);
                        $('#list').editRow(id, true);
                        lastSelectedId = id;
                    }
                },
                afterSubmit: function() {
                    $(this).jqGrid("setGridParam", { datatype: 'json' });
                    return [true];
                    alert("returnvalue");
                }
            });
             }
            function rowColorFormatter(cellValue, options, rowObject) {
                if (cellValue == "unavailable")
                    rowsToColor[rowsToColor.length] = options.rowId;
                return cellValue;
            };
Â
            $("#list").setGridParam({ sortname: 'CalDate', sortorder: 'asc' }).trigger('reloadGrid');
            $("#list").jqGrid('navGrid', '#pager',
                       {
                           edit: false,
                           add: false,
                           del: false,
                           search: true,
                           searchtext: "Search",
                           reloadAfterSubmit: true,
                           cloneToTop: true,
                           overlay: false,
                           beforeRefresh: function() {
                               $("#list").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid');
                               // onEnterrowdetails('#list');
                           }
                       });
Â
            $("#list").jqGrid('editRow', {
                aftersavefunc: function() {
                    onEnterrowdetails('#list');
                }
            });
        });
     Â
        function onEnterrowdetails() {
            $('#<%=lblMessage.ClientID%>').html(" Data Updated......");
            return true;
        }
 </script>
Â
 Â
       <table id="list" ></table>
       <div id="pager" > </div>  Â
  </form>
</body>
</html>
11:46

Moderators
30/10/2007

Hello,
Â
1. afterSubmit will never work. This is not function which is grid option, but in form edit one.
2. gridComplete raises every time you reload the grid and query new page and sort it. It is highly recommended not to use it.
3. Check your logic again.
Â
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
16 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66