0

我有用 FlexiGrid 定义的表。调用所有变量都可以。一列是我用 Simple Color Picker JavaScript 选择的颜色。在开始使用 Flexigrid 之前,我将一列定义为:

<span style="background: <c:out value="${current.colore}" />">&nbsp;&nbsp;&nbsp;</span>

这向我展示了带有精选颜色的小方块。现在我不知道如何做 samo,但使用 FlexiGrid。

我的问题是:如何将 span 标签导入 FlexiGrid 表定义以读取颜色值并在每一行用该颜色绘制一个框?

表的代码是:

$(document).ready(function() {
    $("#newTable").flexigrid({
    url: 'agendaTipoAppuntamentoInitJson.do',
    dataType: 'json',
    colModel : [
        {display: 'ID',                 name : 'idTipoAppuntamento', width : 40, sortable : false, align: 'center', hide: true},
        {display: 'Codice',             name : 'codice', width : 60, sortable : false, align: 'left'},
        {display: 'Descrizione',        name : 'descrizione', width : 130, sortable : false, align: 'left'},
        {display: 'Descr. breve',       name : 'descrBreve', width : 80, sortable : false, align: 'left'},
        {display: 'Colore',             name : 'colore', width : 80, sortable : false, align: 'left'},
        {display: 'ID Struttura',       name : 'idStruttura', width : 60, sortable : false, align: 'left', hide: true},
        {display: 'Descr. Struttura',   name : 'descrizioneStruttura', width : 150, sortable : false, align: 'left'},
        {display: 'ID Spec',            name : 'idSpecializzazione', width : 60, sortable : false, align: 'left', hide: true},
        {display: 'Descr. Spec',        name : 'descrizioneSpecializzazione', width : 150, sortable : false, align: 'left'},
        ],
    usepager: true,
    title: 'Gestione tipi appuntamento',
    useRp: true,
    rp: 15,
    showTableToggleBtn: true,
    width: 950,
    height: 370,
    singleSelect: true,
    click: editMe
}); });
4

1 回答 1

1

我以前经历过类似你的事情。在从您的服务器端发送您的 Json 数据之前尝试放置:

在您的服务器端 - 在将其发送到 flexigrid 之前 - 创建您的 Json 数据,如下所示:

total: (no of rec)
 page : (page no)
 rows : [{cell: [ (col1 value) , <span style="background: <c:out value=" + MyColorValue1 + " />">&nbsp;&nbsp;&nbsp;</span> ,.. ] },
        {cell: [ (col1 value) , <span style="background: <c:out value=" + MyColorValue2 + " />">&nbsp;&nbsp;&nbsp;</span>  ,.. ] }]

如果它没有正确显示您的跨度,请使用 > 和 < 而不是 < 和 >。

于 2012-01-30T15:59:20.733 回答