Well heck 😉
Thanks for the quick response and I am looking forward to the next release.
Ken
So I finally figured it out. Here’s what I did that worked:
[code language=”php”]
$setNav =<<<SETNAV
function() {
var numrecs = $(‘#grid’).jqGrid(‘getGridParam’,’records’);
if (numrecs < 200000) {
$(‘#pager_excel’).show();
} else {
$(‘#pager_excel’).hide();
}
}
SETNAV;
$grid->setGridEvent(‘gridComplete’,$setNav);
$grid->setNavOptions(‘navigator’,array(‘add’=>false,’edit’=>false,’del’=>false,’view’=>true,"columns"=>true));
// Run the script
$grid->renderGrid(‘#grid’,’#pager’,true, null, null, true,true);
[/code]
I’d still like to know how to get code to show up as code after submitting a post though.
Ken
And if you could tell me how to show the code I posted as code I’d appreciate that too.
MymsMan:
I’ve been a customer of their php suite for the past three years or so and I have had the exact same complaint as you regarding their documentation, and I’ve been getting the same promise, that “we know it’s out of date/incomplete and we will have it fixed/updated very soon”.
At this point I doubt that they will ever have decent documentation.
That would make a rather large download. At least I now know that I can just add the table in my local database and if I want I can load it with dummy data.
Thanks for the explanation.
Regards!
Ken
Thanks, Tony.
I for one use the jqCharts library probably more than any other. I’m very relieved that you are working with them to get this done.
Ken
Do you have a plan in place to acquire the rights to distribute the Highcharts library, and if so, when do you expect that to happen?
Oh, I see now what you mean by the problem of the code – I just noticed that you had reformatted it. Not sure what that issue is – I used the code editor and the result is what you see in my post above. This new forum software is really very strange to me, so I guess I am doing something wrong.
I think what would really help me out with this header problem would be an example on your demo page for a multiline pivot grid. Just saying… 😉
No, I am not using a MAC to paste code, I am on a Windows 7 computer. Not sure what you mean by a problem – the code looks Ok to me when I look at that post.
Anyway, it doesn’t matter what colName I use in the setLabels method (the <th> id for the Queue and UpstreamQ headers are grid_East_sum_0, grid_East_sum_1, grid_North_sum_0, grid_North_sum_1, grid_West_sum_0 and grid_West_sum_1) for ANY of the headers – I can’t get the title to change, which leads me to believe that I have the right method but I am applying it wrong.
In my mtas.php code I set a variable:
|
1 2 3 4 |
$hdrTitle = <<< TITLE $("#grid").jqGrid('setLabel', 'East', '', '', { title: 'Available for immediate processing'} ); $("#grid").jqGrid('setLabel', 'North', '', '', { title: 'Waiting for completion by other Network Element'} ); TITLE; |
Then near the end of the script I call it with the setJSCode method (just before the renderPivot call):
|
1 |
$pivot->setJSCode($hdrTitle); |
This doesn’t do anything, so my questions are these:
Do I need a function around the jquery code in the $hdrTitle script (and if so, what would it look like) ?
Is calling the setJSCode($hdrTitle) the appropriate call and placement within the mtas.php script?
Is the id of the <th> line for each of the Queue/UpstreamQ headers the correct name value to use in the setLabels call?
Tony:
So I tried using that code in my script but I guess I am not putting it in the right place because I never see the ‘replaced’ title. Here’s my code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<?php @session_start(); if (!isset($_GET['grp'])) { $grp = $_SESSION['usrgrp'] = '%'; } else { $grp = $_SESSION['usrgrp'] = $_GET['grp']; } include('sqlPDO.php'); $db = opendb('MySQL','MTAS'); $stmt = $db->query("select max(RequestId) from queues"); $row = $stmt->fetch(); $key = $row[0]; $select = "Select a workgroup to display: <select id=\"USRGRP\">\n\t\t\t<option value=\"\"></option>\n\t\t\t<option value=\"%\">All</option>\n"; $sql = "select distinct GroupName from NEType where GroupName <> '' order by GroupName"; foreach ($db->query($sql) as $option) { $select .= "\t\t\t<option value=\"".$option['GroupName']."\">".$option['GroupName']."</option>\n"; } $select .= "\t\t</select>"; $ElementManager[] = '%'; foreach ($db->query("select distinct grp from ElementManager") as $row) { $ElementManager[] = $row['grp']; } if (array_search($grp,$ElementManager)) { //if ($grp == "surepay" || $grp == "asp" || $grp == "m2m" || $grp == "%") { $select .= " Go to the <a href="http://cospcdvappd1v.nss.vzwnet.com/MTAS/AlertMgr.php">Element Alert Manager</a>"; } $select .= "<br /><br />\n"; $ElementManager = json_encode($ElementManager); unset($db); ?> |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&gt; &lt;title&gt;MTAS Queue Monitor&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="/themes/sunny/jquery-ui-1.10.4.custom.min.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="/jqSuite460/themes/ui.jqgrid.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="/jqSuite460/themes/ui.multiselect.css" /&gt; &lt;script src="/JQuery/jquery-1.10.2.min.js"&gt;&lt;/script&gt; &lt;script src="/jqSuite460/js/i18n/grid.locale-en.js"&gt;&lt;/script&gt; &lt;script src="/jqSuite460/js/jquery.jqGrid.min.js"&gt;&lt;/script&gt; &lt;script src="/jqSuite460/js/jquery-ui-1.10.4.custom.min.js"&gt;&lt;/script&gt; &lt;script src="/js/moment.min.js"&gt;&lt;/script&gt; &lt;script src="/jqSuite460/js/jquery.cookie.js"&gt;&lt;/script&gt; &lt;script src="/js/jquery.plugin.js"&gt;&lt;/script&gt; &lt;script src="/js/jquery.countdown.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="/css/mtas.css" /&gt; &lt;script&gt; var start = &lt;?php print $key * 1000; ?&gt;; var intv = start + 350000 - moment().valueOf(); var ex = []; //console.log("start: "+start+" interval: "+intv); //console.log("group is &lt;?php print $grp; ?&gt;"); setTimeout(function() { $("tr[id^='gridghead_0']").each(function() { i = $(this).attr('id'); if ($(this).find("span").hasClass("ui-icon-circlesmall-minus")) { ex.push(i); } }); var myDate = new Date(); myDate.setMinutes(myDate.getMinutes() + 6); $.cookie('NetworkElementTypeGroupsExpanded',ex, { expires: myDate }); location.reload(true); },intv); $(function() { var targDate = new Date(&lt;?php print $key*1000+350000; ?&gt;); $('#cd').countdown({until: targDate, compact: true, format: 'MS', description: ''}); }); $.ajaxSetup({ // Hide or show the animated ajax-loader.gif - it will be visible while the ajax call // is busy querying the database beforeSend: function() { $('#wait').show(); }, complete: function () { $('#wait').hide(); } }); $(document).ready(function() { var ElementManager = Array(&lt;?php print $ElementManager; ?&gt;); var GroupName = "&lt;?php print $grp; ?&gt;"; if (ElementManager[0].indexOf(GroupName) == -1) { $('#other').hide(); $('#timer').css("left","380px"); } }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="hdr"&gt; &lt;?php print $select; ?&gt; &lt;div id="timer"&gt;Page reload in &lt;span id="cd"&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;?php include("mtas.php"); ?&gt; &lt;div id="upick"&gt; &lt;input type="hidden" autofocus="focus" /&gt; &lt;input type="radio" checked name="choice" value="conns"&gt;Show Element Connections&lt;br /&gt; &lt;input type="radio" name="choice" value="ngraph"&gt;Show Element History Graph&lt;br /&gt; &lt;input type="radio" name="choice" value="esgraph"&gt;Show Element Group History Graph (Sum of Elements)&lt;br /&gt; &lt;input type="radio" name="choice" value="pegraph"&gt;Show Element Group History Graph (Per Element)&lt;br /&gt; &lt;/div&gt; &lt;div id="popup"&gt;&lt;/div&gt; &lt;div id="wait"&gt;<img src="/images/ajax-loader.gif" />&lt;/div&gt; &lt;hr&gt; &lt;div id="other"&gt; &lt;!-- &lt;div id="CurAlarms"&gt; --&gt; &lt;?php include('alarms.php'); ?&gt; &lt;table id="alarmsTable"&gt;&lt;/table&gt; &lt;div id="alarmsPager"&gt;&lt;/div&gt; &lt;hr&gt; &lt;!-- &lt;/div&gt; --&gt; &lt;!-- &lt;div id="maintenance"&gt; --&gt; &lt;?php include('maintenance.php'); ?&gt; &lt;table id="maintenanceTable"&gt;&lt;/table&gt; &lt;dir id="maintenancePager"&gt;&lt;/dir&gt; &lt;!-- &lt;/div&gt; --&gt; &lt;/div&gt; &lt;div id="info"&gt; <a href="mailto:kr@noreply.com?subject=MTAS Queue Monitor Question/Comment">Questions? Comments?</a> &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </pre> |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
<?php @session_start(); date_default_timezone_set("US/Central"); require_once('/var/www/html/jqSuite460/jq-config.php'); require_once('/var/www/html/jqSuite460/php/jqPivotGrid.php'); require_once('/var/www/html/jqSuite460/php/jqGridPdo.php'); if (!isset($_SESSION['usrgrp'])) { $grp = '%'; } else { $grp = $_SESSION['usrgrp']; } $db = new PDO(DB_DSN.'MTAS',DB_USER,DB_PASSWORD); $stmt = $db->query("select max(RequestId) from queues"); $row = $stmt->fetch(); $key = $row[0]; $stmt = $db->query("select min(RequestId) from queues"); $row = $stmt->fetch(); $minDate = $row[0]+86400; foreach ($db->query("select Name,threshold from ElementManager") as $row) { $THRESHOLD[$row['Name']] = $row['threshold']; } $THRESHOLD = json_encode($THRESHOLD); $pivot = new jqPivotGrid($db); $pivot->SelectCommand = " SELECT RequestId, q.NetworkElementType 'Element Group', Name 'Element Name', case mtasInstance when 'n' then 'North' when 'e' then 'East' when 'w' then 'West' end as mtasInstance, QueueCount, PWaitingQueueCount FROM queues q, NEType n WHERE RequestId = $key AND GroupName like '".$grp."' AND q.NetworkElementType = n.NetworkElementType GROUP BY q.NetworkElementType, Name, mtasInstance"; $pivot->setData('mtas.php'); $pivot->setGridOptions(array( "rowNum" => 1000, "width" => 'auto', // "height" => 787, "height" => "auto", "sortname" => "Element Group", "rowList" => array(20,40,60,80,1000), "altRows" => true, "headertitles" => true, "caption" => "Queues as of ".date('D, M jS, Y g:i:s A T',$key), "groupingView" => array("groupCollapse" => true) )); $tooltip = <<<TOOLTIP function(rowid,value,rawObject,colModel,arraydata) { var THRESHOLD = $THRESHOLD; if (value in THRESHOLD) { return 'title="' + value + ' (Threshold: ' + THRESHOLD[value] + ')"'; } else { return 'title="' + value + '"'; } } TOOLTIP; $pivot->setxDimension(array( array( "dataName" => "Element Group", "width" => 115), array( "dataName" => "Element Name", "width" => 115, "cellattr" => "js:".$tooltip) )); $pivot->setyDimension(array( array( "dataName" => "mtasInstance") )); $pivot->setaggregates(array( array( "member" => "QueueCount", "aggregator" => "sum", "width" => 80, "label" => "Queue", "formatter" => "integer", "align" => "right", "summaryType" => "sum"), array( "member" => "PWaitingQueueCount", "aggregator" => "sum", "width" => 80, "label" => "UpstreamQ", "formatter" => "integer", "align" => "right", "summaryType" => "sum"), )); $pivot->setPivotOptions(array( "rowTotals" => true )); $custom = <<<CUSTOM function(rowid,iCol,cellcontent,e) { if (iCol == 1) { var opt1 = { autoOpen: false, modal: true, width: 420, height: 200, position: [200,100], title: "Element "+cellcontent, buttons: { "Ok": function() { if ($('input[type=radio][name=choice]:checked').val() == "conns") { $.post( "./connections/index.php", { id: $key, name: cellcontent }, function(result) { WinId = window.open("","Connections","width=960,height=100,top=50,left=50,scrollbars=1"); WinId.document.open(); WinId.document.write(result); WinId.document.close(); }); } if ($('input[type=radio][name=choice]:checked').val() == "ngraph") { $.post( "./elementGraph/index.php", { key: $key, name: cellcontent, minDate: $minDate }, function(result) { WinId = window.open("","EGraph","width=1010,height=490,top=50,left=50"); WinId.document.open(); WinId.document.write(result); WinId.document.close(); }); } if ($('input[type=radio][name=choice]:checked').val() == "esgraph") { $.post( "./elementGroupGraph/index.php", { key: $key, name: cellcontent, minDate: $minDate }, function(result) { WinId = window.open("","EGGraph","width=1010,height=490,top=50,left=50"); WinId.document.open(); WinId.document.write(result); WinId.document.close(); }); } if ($('input[type=radio][name=choice]:checked').val() == "pegraph") { $.post( "./perElementGroupGraph/index.php", { key: $key, name: cellcontent, minDate: $minDate }, function(result) { WinId = window.open("","PEGGraph_e","width=1030,height=490,top=50,left=50"); WinId.document.open(); WinId.document.write(result); WinId.document.close(); }); } if ($('input[type=radio][name=choice]:checked').val() == "other") { window.open("/images/money-stack.png","Shown","width=500,height=333,top=100,left=100"); } $(this).dialog("close"); }, "Cancel": function() { $('#pivot').jqGrid('clearGridData',true); $('#pivot').jqGrid('setGridParam',{datatype: 'json',url: 'mtasUpdate.php'}); $('#pivot').trigger('reloadGrid'); $(this).dialog("close"); } } } $('#upick').dialog(opt1).dialog("open"); } } CUSTOM; $chgGrp = <<<CHG $('#USRGRP').change(function() { location.replace("MTAS.php?grp="+$(this).val()); }); CHG; $hdrTitle = <<<TITLE $("#grid").jqGrid('setLabel', 'QueueCount', '', '', { title: 'Available for immediate processing'} ); $("#grid").jqGrid('setLabel', 'PWaitingQueueCount', '', '', { title: 'Waiting for completion by other Network Element'} ); TITLE; /* $hideme = <<<HIDE $('#MyNETypes').change(function() { $('#grid').trigger('reloadGrid'); var netype = $(this).val(); if (netype == "%") { $('#grid').trigger('reloadGrid'); return false; } $("tr[id^='gridghead_0']").each(function() { if ($(this).find(">:first-child").text() == netype ) { $('#grid').jqGrid("groupingToggle",$(this).attr('id')); } }); netype = ""; }); $("#RFGrid").click(function() { $("#grid").jqGrid('clearGridData', true); $("#grid").jqGrid('setGridParam',{datatype: 'json',url:"mtasUpdate.php"}); $("#grid").trigger("reloadGrid"); }); HIDE; */ $expandRows = <<<EXPAND setTimeout(function() { if ($.cookie('NetworkElementTypeGroupsExpanded')) { var ex2ep = $.cookie('NetworkElementTypeGroupsExpanded'); if (ex2ep.length > 0) { var str = ex2ep.split(','); var ex2epLen = str.length; //console.log("cookie ex2ep: "+str+" elements: "+ex2epLen); for (var i = 0;i < ex2epLen; i++) { //console.log("expand "+str<em class="d4pbbc-italic"></em>); jQuery('#grid').jqGrid('groupingToggle',str<em class="d4pbbc-italic"></em>); } $.removeCookie('NetworkElementTypeGroupsExpanded'); } } }, 500) EXPAND; $pivot->setGridEvent('onCellSelect',$custom); $pivot->setGridEvent('gridComplete',$expandRows); // $pivot->setJSCode($color); // $pivot->setJSCode($hideme); $pivot->setJSCode($chgGrp); $pivot->setJSCode($hdrTitle); $pivot->renderPivot("#grid","#pager", true, null, true, true); ?> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top