Forum
22:36
05/09/2014
I will throw out there VERY honestly - I am not new to coding, but I am clueless when it comes to javascript, jquery, and ajax. Still I have been able to get everything functioning and working that I need. I have mixed and matched a lot of code to get everything working I need.
Here is the problem, I am using a grid as a sub grid, and the first sub grid I need to edit, add, and delete content. Well I can only 'select' the bottom row of data. I'm sure I have something in the wrong place, or an extra closing parenthesis or brace etc. However I have not been able to locate it. I can hover over the other rows, and it shows when I change from one row to the next, but I cannot 'select' them. Even when I 'view records' etc and click the forward and back arrows, it does not go forward and backwards. It stays on the single record (bottom). (I have been through this w/ a fine tooth comb, multiple times, everything has a made, everything 'works' where it is placed, etc...)
Â
   <!--jquery start datagrid components-->    <link rel="stylesheet" type="text/css" href="/Includes/jqgrid/css/jquery-ui.css">    <link rel="stylesheet" type="text/css" href="/Includes/jqgrid/src/css/ui.jqgrid.css">    <script type="text/javascript" src="/Includes/jqgrid/js/jquery-1.11.0.min.js"></script>    <script type="text/javascript" src="/Includes/jqgrid/js/i18n/grid.locale-en.js"></script>    <script type="text/javascript" src="/Includes/jqgrid/js/jquery.jqGrid.src.js"></script>    <script type="text/javascript" src="/Includes/tinymce/tinymce.min.js"></script>    <script type="text/javascript" src="/Includes/tinymce/jquery.tinymce.min.js"></script>    <script type="text/javascript">       jQuery(document).ready(function()       { jQuery("#grid").jqGrid(          {             //main grid             url: "getwellinfo.php",             datatype: "json",             mtype: 'POST',             autowidth: true,             height: 'auto',             colNames: ["Name", "Num", "Field", "Pad", "API", "County, State",                "Status", "Updated", "Wildlife Stips", "Notes"],             colModel:             [                { name: "well_name", index: "well_name", width: 48,sortable: true, search:true, stype:'text'},                { name: "well_num", index: "well_num", width: 18,sortable: true, search:true, stype:'text'},                { name: "field", width: 48,sortable: true, search:true, stype:'select', stype: 'select',                   searchoptions: {dataUrl:'selectfield.php'}},                { name: "pad", index: "pad", width: 36,sortable: true, stype:'text'},                { name: "api", width: 32,sortable: true, search:true, stype:'text',key:true},                { name: "county_state", width: 40, sortable: false, search:false},                { name: "status", width: 27, sortable: false, search:false},                { name: "status_date", width: 22, sortable: false, search:false},                { name: "wildlife_stips", width: 75, sortable: false, search:false},                { name: "notes", width: 75, sortable: false, search:false}             ],             rowNum:20,             rowList:[20,50,100,10000],             pager : '#pager',             viewrecords: true,             rownumbers: true,             sortname: 'field',             sortorder: "asc",             caption:".",             subGrid: true,             subGridRowExpanded: function(subgrid_id, row_id)             {                var subgrid_table_id, subgrid_table_id2, pager_id;                subgrid_table_id = subgrid_id+"_t";                subgrid_table_id2 = subgrid_id+"_t2";                // configuring add options                pager_id = "p_"+subgrid_table_id;                //first grid as sub grid - with editing (add edit delete)                $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");                jQuery("#"+subgrid_table_id).jqGrid(                {                   url:"getwellnotes.php?api="+row_id,                   datatype: "json",                   mtype: 'POST',                   autowidth: true,                   colNames: ['Last','First','Date','API','Notes'],                   colModel:                   [                      {name:"Last",width:28,key:true},                      {name:"First",width:28},                      {name:"date",width:28},                      {name:"api",width:16, hidden:true},                      {name: "notes",   width: 300, editable: true, edittype: 'custom',                         editoptions:                         {                            custom_element: function(value, options)                            {                               var elm = $("<textarea></textarea>");                               elm.val(value);                               // give the editor time to initialize                               setTimeout(function()                               {                                  try                                  {tinymce.remove("#" + options.id);}                                  catch (ex) {}                                  tinymce.init(                                  {                                     selector: "#" + options.id,                                     plugins: "link"                                  });                               }, 50);                               return elm;                            },                            custom_value: function(element, oper, gridval)                            {                               var id;                               if (element.length > 0)                               {id = element.attr("id");}                               else if (typeof element.selector === "string")                               {                                  var sels = element.selector.split(" "),                                     idSel = sels[sels.length - 1];                                  if (idSel.charAt(0) === "#")                                  {id = idSel.substring(1);}                                  else                                  {return "";}                               }                               if (oper === "get")                               {return tinymce.get(id).getContent({format: "row"});}                               else if (oper === "set")                               {                                  if (tinymce.get(id))                                  {tinymce.get(id).setContent(gridval);}                               }                            }                         }                      }                   ],                   rowList: [],                   pgbuttons: false,                   pgtext: null,                   viewrecords: false,                   pager: pager_id,                   height: '100%'                });                //second grid as sub grid                $("#"+subgrid_id).append("<table id='"+subgrid_table_id2+"' class='scroll'></table>");                jQuery("#"+subgrid_table_id2).jqGrid(                {                   url:"getwellfiles.php?api="+row_id,                   datatype: "json",                   autowidth: true,                   colNames: ['File Name','File Type','Size','Description','Last', 'First'],                   colModel: [                      {name:"file_name",width:55, formatter: "link"},                      {name:"file_type",width:18},                      {name:"size",width:68},                      {name:"description",width:28},                      {name:"Last",width:28},                      {name:"First",width:28}                   ],                   height: '100%',                });                //paging bar options for grid as subgrid (first)                  jQuery("#"+subgrid_table_id).jqGrid                (                   'navGrid',                   "#"+pager_id,                   {                      edit: true,                      add: true,                      del: true,                      search: false,                      view: true,                      refresh: true                   },                   {                      /*prmEdit*/                      //url:"notesedit.php?userid="+<?php echo $userid; ?>,                      width: 'auto',                      height: 'auto'                   },                   {                      /*prmAdd*/                      url:"#",                      width: 'auto',                      height: 'auto'                   },                   { /*prmDel*/ } ,                   { /*prmSearch*/ },                   { /*prmView*/ }                );             },             subGridRowColapsed: function(subgrid_id, row_id) {   }                           });          //paging options for main grid          jQuery("#grid").jqGrid          (             'navGrid','#pager',             {                edit: false,                add: false,                del: false,                search: false,                view: true,                refresh: true             },             { /*prmEdit*/ },             { /*prmAdd*/ },             { /*prmDel*/ } ,             {                /*prmSearch*/                multipleSearch:true             },             { /*prmView*/ }          );          //code to hide search bar in main paing bar          $('#grid').jqGrid('filterToolbar', { searchOnEnter: true, enableClear: true });          $('#grid').jqGrid('navButtonAdd', '#pager',          {                caption: "",                title: "Toggle Search Toolbar",                buttonicon: 'ui-icon-search',                onClickButton: function ()             {                    this.toggleToolbar();                    if ($.isFunction(this.p._complete))                {                        if ($('.ui-search-toolbar', this.grid.hDiv).is(':visible'))                   {$('.ui-search-toolbar', this.grid.fhDiv).show();}                   else                   {$('.ui-search-toolbar', this.grid.fhDiv).hide();}                        this.p._complete.call(this);                        fixPositionsOfFrozenDivs.call(this);                    }                }            });          //$('.ui-search-toolbar').hide();          jQuery("#s2").click( function() { jQuery("#grid").jqGrid('setGridParam',{sortname:"api",sortorder:"asc"}).trigger("reloadGrid");});       });        </script>    <!--jquery end datagrid components-->
11:49
Moderators
30/10/2007
Hello,
Â
Thanks for the feedback and let us know.
Yes jqGrid need to have unique ids. key:true is recommended approach for this purpose.
Â
Kind 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:
53 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