Grid column width


#1

Hello,

Maybe this is covered somewhere else however I was not able to find it. Given the following situation: https://prnt.sc/jf8nhy This is a product with a field “Elementen” this is displayed as a grid however the key column is rather small. Is there a way to configure the width of this column somewhere so that I dont have to drag everytime to change the column width. I read somewhere that it is possible to export grid column configuration but I could not find where (https://pimcore.com/docs/5.x/User_Documentation/DataObjects/Grid_Configuration_General.html).

With kind regards, Edwin Jacobs


#2

Hi,

it seems like this is a multihref with metadata element. The key column is not a metadata column right?

According to the code:

//web/pimcore/static6/js/pimcore/object/tags/multihrefMetadata.js
columns.push({text: 'ID', dataIndex: 'id', width: 50});
        columns.push({text: t('reference'), dataIndex: 'path', flex: 1});


        for (i = 0; i < this.fieldConfig.columns.length; i++) {
            var width = 100;
            if(this.fieldConfig.columns[i].width) {
                width = this.fieldConfig.columns[i].width;
            }
....

The “reference” column which is the path or the formatted path, using a path formatter, is a flex column und should expand to the remaining width. The id is a fixed width of 50px and each metadata column can be configured in the class-editor.

regards


#3

Hello,

Thanks for the reply. The type of field is an object reference (object with Metadata?) based on that I found that in objectMetadata.js the following happens:

Blockquote
objectMetadata.js (web/pimcore/static6/js/pimcore/object/tags/objectMetadata.js)
for (i = 0; i < visibleFields.length; i++) {
if (!empty(visibleFields[i])) {
debugger;
var layout = this.fieldConfig.visibleFieldDefinitions[visibleFields[i]];

            var field = {
                key: visibleFields[i],
                label: layout.title == "fullpath" ? t("reference") : layout.title,
                layout: layout,
                position: i,
                type: layout.fieldtype
            };

            var fc = pimcore.object.tags[layout.fieldtype].prototype.getGridColumnConfig(field);

            fc.width = 100;
            fc.hidden = false;
            fc.layout = field;
            fc.editor = null;
            fc.sortable = false;

            columns.push(fc);
        }
    }

Blockquote

The line fc.width = 100 is fixed, hence it seems that it is not possible (except for code overrides) to configure this. Is there a nice way to extend this js? (I am rather new to pimcore)


#4

hi,

yes


#5

Thanks again,

I fixed my issue with the following code (registered in an appropriate bundle)

pimcore.registerNS(“pimcore.object.tags.objectsMetadata”);
pimcore.object.tags.objectsMetadata = Class.create(pimcore.object.tags.objectsMetadata, {

createLayout: function ($super, readOnly) {

    let layout = $super(readOnly);
    let visibleFields = this.fieldConfig.visibleFields.split(",");

    Ext.each(layout.getColumns(), function(column) {
        let columnId = column.config.dataIndex;
        if (!Ext.Array.contains(visibleFields, columnId)) {
            return;
        }

        column.setWidth(null);
        column.setFlex(1);

    });

    return layout;
},

});


#6

Maybe you should also try creating a PR on github for that, guess that should be configurable in the backend.