tud / plmexplorer Goto Github PK
View Code? Open in Web Editor NEWapplicazione per visualizzazione dati PLM
Home Page: http://www.plmexplorer.com
applicazione per visualizzazione dati PLM
Home Page: http://www.plmexplorer.com
This bug is related to ASP.Net grid output.
Header part (column names) are generated in tBody section in th tags. That leads to situation that tabletogrid creates one empty row.
Suggestion is to:
data.push(row)
and data fill put under if statement:
i if (
data.push(row);
if (rowPos == 0 && selectable) {
var input =
var rowId = input.attr("value");
rowIds.push(rowId || data.length);
if (input.attr("checked")) {
rowChecked.push(rowId);
}
row[colModel[rowPos].name] = input.attr("value");
} else {
row[colModel[rowPos].name] = $(this).html();
}
rowPos++;
});
}
Not perfect solution, but it works
Hello,
tabletogrid function is great but it misses jqgrid parameters. And setGridParam have no effect on such grids. Update is made that default parameters will not be overwritten. Code bellow makes grid from table + optional parameters:
/*
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, parameters) {
$(selector).each(function() {
if (this.grid) { return; } //Adedd from Tony Tomov
// This is a small "hack" to make the width of the jqGrid 100%
$(this).width("99%");
var w = $(this).width();
// Text whether we have single or multi select
var inputCheckbox = $('input[type=checkbox]:first', $(this));
var inputRadio = $('input[type=radio]:first', $(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 = [];
$('th', $(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: $(this).html(),
index: $(this).html(),
width: $(this).width() || 150
});
colNames.push($(this).html());
}
});
var data = [];
var rowIds = [];
var rowChecked = [];
$('tbody > tr', $(this)).each(function() {
var row = {};
var rowPos = 0;
data.push(row);
$('td', $(this)).each(function() {
if (rowPos == 0 && selectable) {
var input = $('input', $(this));
var rowId = input.attr("value");
rowIds.push(rowId || data.length);
if (input.attr("checked")) {
rowChecked.push(rowId);
}
row[colModel[rowPos].name] = input.attr("value");
} else {
row[colModel[rowPos].name] = $(this).html();
}
rowPos++;
});
});
// Clear the original HTML table
$(this).empty();
// Mark it as jqGrid
$(this).addClass("scroll");
if (parameters == null)
parameters = {
datatype: "local",
width: w,
colNames: colNames,
colModel: colModel,
multiselect: selectMultiple
};
else {
parameters.datatype = "local";
parameters.width = w;
parameters.colNames = colNames;
parameters.colModel = colModel;
parameters.multiselect = selectMultiple;
};
$(this).jqGrid(parameters);
// Add data
for (var a = 0; a < data.length; a++) {
var id = null;
if (rowIds.length > 0) {
id = rowIds[a];
if (id && id.replace) {
// We have to do this since the value of a checkbox
// or radio button can be anything
id = encodeURIComponent(id).replace(/[.\-%]/g, "_");
}
}
if (id == null) {
id = a + 1;
}
$(this).addRowData(id, data[a]);
}
// Set the selection
for (var a = 0; a < rowChecked.length; a++) {
$(this).setSelection(rowChecked[a]);
}
});
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.