3

I'm building out an admin ui with the built in components, and i have an actionsColumn that i'm using. The label of the said actionsColumn is long, and i want the layout to not wrap the words, so i'm using the config that i see all over the core core (i.e. - vendor/magento/module-search/view/adminhtml/ui_component/search_synonyms_grid.xml) to do this:

<actionsColumn name="actions" class="Vendor\Namespace\Ui\Component\Grid\Amazon\Account\Menu\Delete">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="resizeEnabled" xsi:type="boolean">true</item>
            <item name="resizeDefaultWidth" xsi:type="string">107</item>
            <item name="indexField" xsi:type="string">account_id</item>
            <item name="sortOrder" xsi:type="number">50</item>
            <item name="label" xsi:type="string" translate="true">Delete Action</item>
        </item>
    </argument>
</actionsColumn> 

But no matter what value i place in the resizeDefaultWidth node i get the same size in the final layout (i have 107 in there now, as i see this all over core code but any value in there give the same result).

One thing i have noticed, it that on page load, before the content is loaded, the label area is bigger then after the page content is loaded. I know a lot of voodoo is going on there, which is why i think resizeEnabled need to be false.

Also the sortOrder seems to not be working either. Which might be a default of actionsColumn as they are suppose to be at the end of the grid (i'm making the assumption that if i had 3 action column, that the sort order with sort those three).

An ideas out there? Is this a bug in M2? or is there a config that i'm missing here?

  • 1
    yea im facing the same issue – Yehia A.Salam Jun 16 '17 at 15:15
  • I want to do some more testing, but i'm thinking this is a bug. I started looking at the core files, but it gets a little convoluted, and i had to move on. But if i find a solution, i will post it here. – circlesix Jun 16 '17 at 15:19
  • 1
    I see that the xsi:type of your resizeDefaultWidth is string. Make it number. I don't think it will make a difference, but try it anyway. – Marius Jun 22 '17 at 19:42
6
+100

I can explain the sort order problem.
Took me 2 hours to find it some time ago.
The grids built with ui-components have their settings stored in the table ui_bookmark.
Even if you don't change anything in the grid, just by viewing it, you get a record in the table ui_bookamrk.
THe grid is rendered based on what the row in this table looks like, merged with the ui component xml.
That's why when you add a new column, you will see it last. Because it first renders what's saved in ui_bookmark.
Clear the contents of that table where user_id = {your admin id}.
If you are on a dev env, just delete everything from that table.

Honestly, I wouldn't be surprised if this fixes your column width problem also.

  • I gave this a try, but it's still not responding as expected. I did try setting resizeDefaultWidth to both string and number, just in case that might make a difference. After truncating the ui_bookmark table, i see that is repopulating with new content, so i don't think i'm on the wrong db, or this is a read/write issue for just my local install. I have also been sure to delete cache and view_preprocessed with each change. Any other ideas? – circlesix Jun 23 '17 at 15:41
  • I did try to de-bug the JS file where i "think" the resize is happening (vendor/magento/module-ui/view/base/web/js/grid/resize.js) but even placing a console.log in the file's initialize function doesn't return anything. This file is the only place where resizeDefaultWidth shows up (outside of uses in xml). So it's almost like resize.js is not getting called at all on the page. – circlesix Jun 23 '17 at 15:55
  • I haven't had time to dig any deeper into why this still isn't working. When i track it down, i will post here. – circlesix Jun 29 '17 at 16:59
  • 1
    Sorry. Me neither. Will do the same if I track something – Marius Jun 29 '17 at 17:04
  • you're a busy man! I think i have a little more free time – circlesix Jun 29 '17 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.