Как выровнять данные столбцов сетки jstree «вправо» или «влево»? - PullRequest
0 голосов
/ 09 октября 2018

Я работаю над сеткой jsTree.Я успешно отрисовал сетку в своем пользовательском интерфейсе, но я хочу выровнять данные столбца вправо или влево.Я хочу выровнять NOOFBILLS вправо.Ниже мой код JS.Пожалуйста, может кто-нибудь, кто знает об этом, поможет мне?

$(document).ready(function() {
    $("#formid").submit(function(event) {
        event.preventDefault(); // to stop form being submitted because it reloads the page.
        $.ajax({
            url: "Drilldown",
            method: "GET",
            success: function(data) {
                $("#formid").hide();
                $("div#jstree").jstree({
                    plugins: ["grid", "dnd", "contextmenu", "ui", "themes", "html_data"],
            core: {
                data: data
            },
            // configure tree table
            grid: {
                columns: [{
                    width: 'auto',
                    header: "Outlet"
                }, {
                    width: 'auto',
                    value: "itemcode",
                    header: "NoOfBills"
                }, {
                    width: 'auto',
                    value: "totalAmount",
                    header: "Amount"
                }],
            resizable: true,
            width: 5000,
            height: 3000
        }
    });
 }
 });
 });
});

1 Ответ

0 голосов
/ 11 октября 2018

CSS-КОД:

<style type="text/css">
    .aright {
        // write here your css to make text right align
    }
    .acenter {
        // write here your css to make text center align
    }
    .aleft {
        // write here your css to make text left align
    }
</style>

JS-КОД:

$(document).ready(function() {
    $("#formid").submit(function(event) {
        event.preventDefault(); // to stop form being submitted because it reloads the page.
        $.ajax({
            url: "Drilldown",
            method: "GET",
            success: function(data) {
                $("#formid").hide();
                $("div#jstree").jstree({
                    plugins: ["grid", "dnd", "contextmenu", "ui", "themes", "html_data"],
                    core: {
                        data: data
                    },
                    // configure tree table
                    grid: {
                        columns: [{
                            width: 'auto',
                            header: "Outlet",
                            cellClass: "aright"
                        }, {
                            width: 'auto',
                            value: "itemcode",
                            header: "NoOfBills",
                            cellClass: "acenter"
                        }, {
                            width: 'auto',
                            value: "totalAmount",
                            header: "Amount",
                            cellClass: "aleft"
                        }],
                        resizable: true,
                        width: 5000,
                        height: 3000
                    }
                });
            }
        });
    });
});

Согласно ссылке на документацию: https://github.com/deitch/jstree-grid#options

ключ "columns" имеет опцию "cellClass"как и другие параметры «ширина» и т. д. Таким образом, вы можете использовать параметр «cellClass» для выравнивания текста ячейки по правому / левому краю или по центру в соответствии с требованием.

Вы можете создавать классы для выравниванияесли их уже нет.

Попробуйте, это должно сработать.

...