Javascript 是否可以更改struts2 jquery网格标记的css颜色
如何更改struts2 jquery网格标记的css样式 我甚至不能改变我的标题层字体大小。任何人都能告诉我,如何像普通html元素一样更改网格样式、颜色和其他格式。使用:Javascript 是否可以更改struts2 jquery网格标记的css颜色,javascript,jquery,css,html,struts2,Javascript,Jquery,Css,Html,Struts2,如何更改struts2 jquery网格标记的css样式 我甚至不能改变我的标题层字体大小。任何人都能告诉我,如何像普通html元素一样更改网格样式、颜色和其他格式。使用: <%@ taglib prefix="sj" uri="/struts-jquery-tags"%> ... <sj:head jqueryui="true" jquerytheme="customTheme" customBasepath="relative/pat
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
...
<sj:head jqueryui="true"
jquerytheme="customTheme"
customBasepath="relative/path/customThemesFolder"/>
在css、图像等内部,主题是您所需要的。小心-页面中的css导入或您拥有的内容必须遵循之前的jqgrid样式。
人们说如果不起作用,就把这个放在这一页的末尾:
<script>
$.subscribe('loadCustomCss', function(event,data){
$.struts2-jquery.requireCss(cssFile, basePath);
});
</script>
如果仍不起作用,请尝试此脚本(而不是上一个脚本):
$.subscribe('loadCustomCss',函数(事件、数据){
$('head').append($(''.attr('href','../customThemeFolder/myTheme.css'));
});
注意相对路径。网格的css是从struts-jquery-grid-plugin.jar动态加载的
template/themes/ui.jqgride.css.
打开这个文件,你会发现css键,你可以骑
另一方面,如果不想更新和添加jqgride css,可以从网格中动态删除css
下面是一段删除一些默认值的代码
$.subscribe('grid_compelete', function(event, data) {
//remove mouse over color change
$($("#gridtable")[0].grid.hDiv).find(".ui-jqgrid-labels th.ui-th-column").unbind("mouseenter").unbind("mouseleave");
//Change header color
$($("#gridtable")[0].grid.hDiv).find(".ui-jqgrid-labels th.ui-th-column").addClass("yourClassColor");
//remove the 'ui-' from the css classes which automaticly created by grid tag
//the gbox_gridtable is the most top element in the grid
$('#gbox_gridtable').find('*').andSelf().attr('class',
function(i, css){
if (typeof css !== 'undefined') {
return css.replace(/\ui-\S+/g, '');
}
});
// remove default td title in jquery grid
$("td").each(function() {
var td = $(this);
if (td.attr("role") == "gridcell") {
td.removeAttr("title");
};
});
});
在jsp中:
<sjg:grid id="gridtable" onGridCompleteTopics="grid_compelete"
更改css有什么问题吗?我使用的是默认的struts2-jquery-grid。因此网格默认为蓝色。我不知道默认struts2 jquery网格的css源。我包括了这几行,并且在customBasePath中包括了jquery-ui-1.10.4.custom.css。但它不起作用。我只从themeroller复制了这个文件jquery-ui-1.10.4.custom.css。是否有必要将theme roller的所有文件复制并粘贴到我们的项目中(webContent)
template/themes/ui.jqgride.css.
$.subscribe('grid_compelete', function(event, data) {
//remove mouse over color change
$($("#gridtable")[0].grid.hDiv).find(".ui-jqgrid-labels th.ui-th-column").unbind("mouseenter").unbind("mouseleave");
//Change header color
$($("#gridtable")[0].grid.hDiv).find(".ui-jqgrid-labels th.ui-th-column").addClass("yourClassColor");
//remove the 'ui-' from the css classes which automaticly created by grid tag
//the gbox_gridtable is the most top element in the grid
$('#gbox_gridtable').find('*').andSelf().attr('class',
function(i, css){
if (typeof css !== 'undefined') {
return css.replace(/\ui-\S+/g, '');
}
});
// remove default td title in jquery grid
$("td").each(function() {
var td = $(this);
if (td.attr("role") == "gridcell") {
td.removeAttr("title");
};
});
});
<sjg:grid id="gridtable" onGridCompleteTopics="grid_compelete"