0

I have a grid with windegColumns. And it all works right. But if you manually hide the Num column, the tagfild widget does not work correctly. New values are not set, old values are not deleted. Unsaved values are reset. In my application, I need to dynamically hide or show the column containing the widget at the click of a button. But when I do this, my Tagfield breaks

My fiddle: https://fiddle.sencha.com/#view/editor&fiddle/3db6

Just hide the Num column in the table and try to change the Tegfield value and you will see

Any idea why this is happening and how to fix it?

Ellen
  • 87
  • 6

2 Answers2

1

It looks like there might be a bug with using the dataIndex instead of bind. Per the docs, you get a record property for each row for free, and if it doesn't work, you may have to explicitly set a rowViewModel. I would recommend using binding here regardless:

xtype: 'widgetcolumn',
cellWrap: true,
text: 'Phone',
// Notice I took out the dataIndex here
flex: 1,
widget: {
    xtype: 'tagfield',
    // Added bind
    bind: {
        value: '{record.phone}'
    },
    // rest of code
incutonez
  • 3,241
  • 9
  • 43
  • 92
  • It doesn't work for me. Because I have 5 columns of widgets. If you put a bind value and remove the dataIndex, all the fields won't work correctly – Ellen Apr 26 '21 at 19:43
  • I don't understand your comment. I was able to do as I posted above in your Fiddle, and all worked fine. You mentioned something about 5 columns, but in your Fiddle, there are only 3 columns. – incutonez Apr 26 '21 at 20:02
  • There are three columns in fiddle. This is just an example. But my application has a table where all the columns are widgets Okay. This a new fiddle. https://fiddle.sencha.com/#view/editor&fiddle/3dbk This is a grid where all the columns are widgetcolumns. The Name column is hidden by default Try setting values for different rows of the Phone column. You will see that values are set on one line, but if you try to set values for another line, something strange happens – Ellen Apr 26 '21 at 20:50
  • @Ellen Okay, have a look at [this Fiddle](https://fiddle.sencha.com/#view/editor&fiddle/3dbm). There was some sort of layout issue happening in your Fiddle, so I forked it and am using a `Viewport` as my main container... there's something weird with rendering to the body like that in your Fiddle. – incutonez Apr 27 '21 at 02:33
  • I found my problem, but I don't know how to solve it. It's not because of Viewport. When I hide one widgetcolumn, onWidgetAttach automatically starts. And because the widgetcolumn is hidden, onWidgetAttach gets runs in an endless loop and doesn't work as it should I don't know what to do about it – Ellen Apr 28 '21 at 08:46
  • So you're saying this happens with the viewport as well? There was definitely some layout issue happening, and I had seen an `x-grid-item-container` flickering in the DOM... It was being added and removed, and a refreshSize method was being called indefinitely. – incutonez Apr 28 '21 at 14:38
  • The framework is tripping up on how your grid is rendered/laid out. If you set an explicit height on your grid, it fixes your issue. If you can't have your app in a `Viewport`, and you must render to the body, I would recommend always setting a height/width or potentially using `plugins: { viewport: true }` from [Ext.plugin.Viewport](https://docs.sencha.com/extjs/7.3.1/classic/Ext.plugin.Viewport.html). The `Viewport` has smarts to determine how things should be properly laid out on the body. – incutonez Apr 28 '21 at 16:02
0

After removing the dataIndex from your tagfield column, the selecting of new values or removing or retaining after hiding the column works properly. A similar fiddle was available where the dataIndex was not provided. Still, not sure why it behaves like this. It probably does not store the selected values anywhere and reloads the widget store. Tried the same with combobox but it just resets the fields and still allows selecting of values after we hide the column.

wahab memon
  • 2,193
  • 2
  • 10
  • 23
  • The fiddle you are talking about has only one widget column and so everything works fine. But in my case I have a grid where all columns are widgets. With this implementation everything breaks if you hide the column – Ellen Apr 26 '21 at 19:45