This is a migrated thread and some comments may be shown as answers.

Databinder : element undefined after calling clearAllFiles with kendoUpload

2 Answers 84 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
moosh
Top achievements
Rank 1
moosh asked on 27 Jul 2020, 06:36 AM
Hello,

I defined a custom "required" binding with kendo.data.binders :

kendo.data.binders.required = kendo.data.Binder.extend({
    init: function(element, bindings, options) {
        Kendo.data.Binder.fn.init.call(this, element, bindings, options);
    },
    refresh: function() {
        var required = this.bindings['required'].get();
        
        $(this.element).prop('required', !!required);
        if($(this.element).getKendoUpload()) console.log('required changed');
    }
});


And my input file : 
<input type="file" data-role="kendoUpload" name="file0" data-bind="required: myCheckFunction">


The console.log display "required changed" correctly but after calling the clearAllFiles/clearFile/removeAllFiles/removeFile method of the kendo upload widget, the log is no longer displayed because "this.element" is undefined.

What the problem ?


I tried to define the required binding in kendo.data.binders.widget.required instead of kendo.data.binders.required but, I don't know why, even if the input is a widget, the event binding is called in the kendo.data.binders.required.

Thanks a lot.
moosh

2 Answers, 1 is accepted

Sort by
0
moosh
Top achievements
Rank 1
answered on 27 Jul 2020, 06:38 AM

Little precision.

Calling the clearAllFiles/clearFile/removeAllFiles/removeFile method of the kendo upload widget OR clicking on the cross icon next to the file in the file list, generate the problem.

0
Ivan Danchev
Telerik team
answered on 28 Jul 2020, 03:11 PM

Hello Moosh,

While it is possible to extend the functionality of the widgets, to achieve something that is not available out-of-the-box, we don't support this officially. I'll leave this thread open, in case someone from the community has implemented required binding in the Upload and could provide more insight.

Alternatively, we have a Professional Services team that specializes in extending widgets and source code modifications aimed at creating custom behavior.

Regards,
Ivan Danchev
Progress Telerik

Tags
MVVM
Asked by
moosh
Top achievements
Rank 1
Answers by
moosh
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or