当前位置: 首页 > 工具软件 > jqxGrid > 使用案例 >

【jQwidgets】jqxGrid 绑定格式化

充星腾
2023-12-01
var cellsrenderer = function(row, columnfield, value, defaulthtml, columnproperties) {
    if ((row == 1) || (row == 3) || (row == 5)) {
        var formattedValue = value;
        if (columnproperties.cellsformat == "yyyy-MM-dd" || columnproperties.columntype == 'datetimeinput') {
            formattedValue = $.jqx.dataFormat.formatdate(formattedValue, columnproperties.cellsformat);
        }
        else if (columnproperties.cellsformat != "") {
            formattedValue = $.jqx.dataFormat.formatnumber(formattedValue, columnproperties.cellsformat);
        }
        return '<div style="height: 100%; background-color: #BBBBBB;"><span style="float: ' + columnproperties.cellsalign + '; position: relative; margin: 4px;">' + formattedValue + '</span></div>';
    };
};
$("#jqxgrid").jqxGrid({
    autoheight: true,
    source: dataAdapter,
    editable: true,
    selectionmode: 'singlecell',
    columns: [
        {
        text: 'First Name',
        datafield: 'firstname',
        width: 90,
        cellbeginedit: beginedit,
        cellsrenderer: cellsrenderer},
    {
        text: 'Ship Date',
        datafield: 'date',
        width: 90,
        cellsalign: 'right',
        cellsformat: 'yyyy-MM-dd',
        cellbeginedit: beginedit,
        cellsrenderer: cellsrenderer,
        }]
});
 

 类似资料: