jqGrid formatting issue within wordpress
-
Hi I’m trying to add jqGrid to my wordpress page but it doesn’t align properly when I do so. The ID column is never populated for some reason and the data starts populating in the next column over. If I create the jqGrid outside of wordpress the formatting is fine and the ID column is populated correctly.
Following examples I’ve used wp_enqueue_ and wp_register_ for styles and javascript in my functions.php file which sounds like the way to do things (best practices) as far as I’ve read?
Then I create a page within wordpress to run the script.
My source code is below as well as screenshots.
<script type="text/javascript"><!--//--><![CDATA[//><!-- //wordpress page jQuery(document).ready(function(){ jQuery("#list2").jqGrid({ url:'src/view_reservations.php', datatype: "json", colNames:['id','Equipment Name', 'Equipment Type', 'Equipment ID','Equipment Description'], colModel:[ {name:'eq_id',index:'eq_id', width:20,sorttype:'int',key:true}, {name:'equipment_name',index:'equipment_name', width:90}, {name:'equipment_type',index:'equipment_type', width:100}, {name:'equipment_id',index:'equipment_id', width:75}, {name:'equipment_description',index:'equipment_description', width:100} ], rowNum:10, rowList:[10,20,30], pager: '#pager2', sortname: 'eq_id', height: 255, width: 800, idPrefix: 'abc', viewrecords: true, sortorder: "desc", caption:"Player List" }); jQuery("#list2").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false}); }); //--><!]]></script> <table id="list2"></table> <div id="pager2"></div>
<?php //functions.php function register_plugin_styles() { wp_register_style( 'my-plugin', '/jquery-ui-1.11.0.custom/jquery-ui.theme.css' ); wp_enqueue_style( 'my-plugin' ); wp_register_style( 'my-plugin2', '/jquery.jqGrid-4.6.0/css/ui.jqgrid.css' ); wp_enqueue_style( 'my-plugin2' ); } // Register style sheet. add_action( 'wp_enqueue_scripts', 'register_plugin_styles' ); function theme_javascript() { wp_register_script("jquery"); wp_enqueue_script( 'jquery' ); wp_register_script("jqgridm","/jquery.jqGrid-4.6.0/js/i18n/grid.locale-en.js", array( "jquery" ),"1.0"); wp_enqueue_script( 'jqgridm' ); wp_register_script("jqgrids","/jquery.jqGrid-4.6.0/js/jquery.jqGrid.min.js", array( "jquery" ),"1.0"); wp_enqueue_script( 'jqgrids' ); } // Add action to enqueue scripts add_action('wp_enqueue_scripts','theme_javascript');
Images here.
https://tinyurl.com/pw6qf6s
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘jqGrid formatting issue within wordpress’ is closed to new replies.