JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://www.guriddo.net/demo/js/jquery.min.js"></script>
<script src="http://www.guriddo.net/demo/js/trirand/jquery.jqGrid.min.js"></script>
<script src="http://www.guriddo.net/demo/js/trirand/i18n/grid.locale-en.js"></script>
<link rel="stylesheet" href="http://www.guriddo.net/demo/css/jquery-ui.css">
<link rel="stylesheet" href="http://www.guriddo.net/demo/css/trirand/ui.jqgrid.css">
<INPUT name="CRM_account_accountid" class="form-control" id="input_0" aria-required="true" style="display: none;" required="">
<TABLE id="grid_0">
<TBODY>
<TR>
<TH></TH>
<TH width="10%" id="column_1">Name</TH>
<TH width="40%" id="column_2">Address1</TH>
<TH width="10%" id="column_3">Address2</TH>
<TH width="40%" id="column_4">Post Code</TH>
</TR>
<TR>
<TD>
<INPUT type="radio" value="7569eeca-6077-e111-87b1-00155d00160f">
</TD>
<TD>A Store (sample)</TD>
<TD> 5009 Orange Street</TD>
<TD></TD>
<TD> 20175</TD>
</TR>
<TR>
<TD>
<INPUT type="radio" value="7769eeca-6077-e111-87b1-00155d00160f">
</TD>
<TD>Advanced Components (sample)</TD>
<TD> 100 Red Oak Lane</TD>
<TD></TD>
<TD> 20313</TD>
</TR>
<TR>
<TD>
<INPUT type="radio" value="7969eeca-6077-e111-87b1-00155d00160f">
</TD>
<TD>Affordable Equipment (sample)</TD>
<TD> 4405 Balboa Court</TD>
<TD></TD>
<TD> 95486</TD>
</TR>
<TR>
<TD>
<INPUT type="radio" value="a1192c27-99bb-e511-9fad-00155d00160f">
</TD>
<TD>Affordable Equipment (sample)</TD>
<TD> The Street</TD>
<TD> The Area</TD>
<TD> The Post Code</TD>
</TR>
<TR>
<TD>
<INPUT type="radio" value="b5018d08-43d6-e511-a1f4-00155d00160f">
</TD>
<TD>astoria</TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD>
<INPUT type="radio"...
JavaScript
/*
Transform a table to a jqGrid.
Peter Romianowski <[email protected]>
If the first column of the table contains checkboxes or
radiobuttons then the jqGrid is made selectable.
*/
// Addition - selector can be a class or id
function tableToGrid(selector, options) {
jQuery(selector).each(function() {
if(this.grid) {return;} //Adedd from Tony Tomov
// This is a small "hack" to make the width of the jqGrid 100%
jQuery(this).width("99%");
var w = jQuery(this).width();
// Text whether we have single or multi select
var inputCheckbox = jQuery('tr td:first-child input[type=checkbox]:first', jQuery(this));
var inputRadio = jQuery('tr td:first-child input[type=radio]:first', jQuery(this));
var selectMultiple = inputCheckbox.length > 0;
var selectSingle = !selectMultiple && inputRadio.length > 0;
var selectable = selectMultiple || selectSingle;
//var inputName = inputCheckbox.attr("name") || inputRadio.attr("name");
// Build up the columnModel and the data
var colModel = [];
var colNames = [];
jQuery('th', jQuery(this)).each(function() {
if (colModel.length === 0 && selectable) {
colModel.push({
name: '__selection__',
index: '__selection__',
width: 0,
hidden: true
});
colNames.push('__selection__');
} else {
colModel.push({
name: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(' ').join('_'),
index: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(' ').join('_'),
width: jQuery(this).width() || 150
});
colNames.push(jQuery(this).html());
}
});
var data = [];
var rowIds = [];
var rowChecked = [];
jQuery('tbody > tr', jQuery(this)).each(function() {
var row = {};
var rowPos = 0;
jQuery('td', jQuery(this)).each(function() {
if (rowPos === 0 && selectable) {
var input = jQuery('input', jQuery(this));
var rowId = input.attr("value");
rowIds.push(rowId || data.length);
if...