Closed anvial closed 7 years ago
Hum maybe it's a bug, I need to investigate more on this, as a quick fix I think you can add
this.data.dashboard._calculPositions();
after setting the new size. It should fix the size I think. Let me know. I'll try to fix this soon
Thank You, quick fix gives the expected behaviour.
Should be ok now on version 1.1.7, use setSize
instead of ref.size =...
Yeap, with .setSize
it works correctly. Thanks for your work.
I call to setSize method from inside my custom widget, and it not work. It not update the widget with the new size. Only if i drag de widget, it is updated. This is my code:
`@Component({ selector: 'widget1', templateUrl: '/vistas/widget1.html', providers: [{ provide: WidgetComponent, useExisting: forwardRef(() => Widget1) }] }) export class Widget1 extends WidgetComponent { @Input() public widgetId: string; @Input() public size: number[];
@ViewChild(WidgetHandleDirective) protected _handle: WidgetHandleDirective;
constructor(ngEl: ElementRef, renderer: Renderer2) { super(ngEl, renderer); }
updateSize(width:number, height: number): void { this.setSize([width, height]); }
}`
Can you help me? Thanks, and sorry for my english!
@diegodbg86 is it a widget that you add dynamically ? I just notice that it doesn't work for widget directly added under <dashboard>
tag. I'll try to fix it asap
if you call this.dashboard.refreshWidgets() after setting the size, it works.
Hey Also .. never got an answer on a question I posted... is there a way to set the widget sizing based on the content of the widget.... instead of specifying a size of how many rows / columns.
@cyborgdoom no it's not possible sorry, I only manage specific sizes, you need to calculate this size depending on your widget's content manually to set it
@jaumard You should add this in as a feature... it would make this a bit more powerful.
@cyborgdoom I don't need it for my current projects as the content of my widget are all dynamic depending of the size of widgets, not the other way around. And I don't think I will have the time to add this feature, also it can add a lot more complexity to add this mode and also keep the current one as it is
I add my widgets directly, but I think that I have the same problem if I add dynamically, because I want to update the size within each widget component, not from dashboard component. I think its a good feature to add. Thanks for your work!
Hello,
I try to set the size of custom widget: addWidget() { const ref: TestWidgetComponent = this.data.dashboard.addItem(TestWidgetComponent); ref.widgetId = this.c2Service.generateUUID(); ref.size = [1, 2]; }
But firstly it renders with default size: @Input() public size: number[] = [1, 1];
And only I move this widget it renders properly.
On add:
After moving:
Thank You.