Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
On updation of jqgrid color does not comes until refresh is clicked.
05/11/2014
16:45
Avatar
mcfarland
Member
Members
Forum Posts: 11
Member Since:
07/10/2014
sp_UserOfflineSmall Offline

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>

09/11/2014
11:46
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
80 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information