)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to add additional text box in the Upload box's dialog ?

Platform: jQuery |
Control: ejUploadbox |
Published Date: July 12, 2018 |
Last Revised Date: May 9, 2019

To add additional fields to the Uploadbox’s dialog, override the internal _pushFileDetails method to include the new elements. The internal methods can be overridden as follows:

Javascript

<script type="text/javascript"> 
    ej.Uploadbox.prototype._pushFileDetails = function (files) { 
         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
    }; 
</script> 

 

Render and add the header for the new textbox.

Javascript

var addbox; 
addbox = $("<div class='e-file-head e-head-box'>Text</div>"); // adding header for the textbox 
$(addbox).appendTo(addedheading); // adding to the heading container element 

 

Then, create the textbox element with necessary class to provide styles.

Javascript

addedfilebox = $("<div class='e-file-size e-file-view'><div class='e-file-box'><input class='e-filetxt' type='text' /></div>"); // creating textbox element 

 

Once it is created, append it to the container element.

Javascript

$(addedfilebox).appendTo(addedlist); // appending to the container element 

 

Refer to the following combined code snippet.

Javascript

<script type="text/javascript"> 
    ej.Uploadbox.prototype._pushFileDetails = function (files) { 
        var fileListDetails, addedFile, actionlist, i, action, me, diaObj, addedlist, addedheading, addname,addbox, addsize, addstatus, addaction, addedfilename, addedfilebox, addedfilestatus, addedfilesize, addedfileaction, filedialog, DialogContentContainer, dialogActions, fileListActions; 
        addedheading = $("<div class='e-head-content'></div>"); 
        addname = $("<div class='e-file-head e-head-name'>" + this._getLocalizedLabels("name") + "</div>"); 
        addbox = $("<div class='e-file-head e-head-box'>Text</div>"); // adding header for the textbox 
        addsize = $("<div class='e-file-head e-head-size'>" + this._getLocalizedLabels("size") + "</div>"); 
        addstatus = $("</div><div class='e-file-head e-head-status'>" + this._getLocalizedLabels("status") + "</div>"); 
        if (this.model.customFileDetails.name) $(addname).appendTo(addedheading); 
        $(addbox).appendTo(addedheading); // adding to the heading container element 
        if (this.model.customFileDetails.size) $(addsize).appendTo(addedheading); 
        if (this.model.customFileDetails.status) $(addstatus).appendTo(addedheading); 
        me = this; 
        filedialog = this.updialog; 
        if (filedialog && filedialog.length != 0) { 
            if (this.model.showFileDetails) { 
                this.control.id != "" ? DialogContentContainer : DialogContentContainer = this.element; 
                if (this.updialog) this.updialog.find(".e-uploadbtn").removeAttr('disabled').removeClass('e-disable'); 
                me.diaObj.open(); 
            } 
        } else { 
            this.updialog = ej.buildTag('div.e-uploaddialog#' + this.element[0].id + '_dialog', "", {}, { 'title':this._getLocalizedLabels("title") }); 
            if (this.model.allowDragAndDrop && !this.model.showBrowseButton) { 
                this.dragWrapper.append(this.updialog); 
                DialogContentContainer = "#" + this.control.id + '_dragWrapper'; 
            } 
            else { 
                this.element.append(this.updialog); 
                this.control.id != "" ? DialogContentContainer = "#" + this.control.id : DialogContentContainer =this.element; 
            } 
        } 
        var fileListDetails, addedFile; 
        fileListDetails = this.updialog.find(".e-ul"); 
        if ($(this.updialog.find(".e-head-content"))) 
            $(this.updialog.find(".e-head-content")).replaceWith(addedheading); 
        if (fileListDetails.length == 0) { 
            addedheading.appendTo(this.updialog); 
            fileListDetails = ej.buildTag('ul.e-ul').appendTo(this.updialog); 
        } 
        if ($(this.updialog).find('.e-file-upload').length > 0) 
            $(this.updialog).find('.e-file-upload').remove(); 
        fileListActions = ej.buildTag('div.e-file-upload').appendTo(this.updialog).append((this.model.autoUpload || !this.model.asyncUpload) ? $(ej.buildTag('div.e-action-container')).addClass("sync") : ej.buildTag('div.e-action-container')); 
        dialogActions = ej.buildTag('button.e-uploadclosebtn e-btn e-select', this._getLocalizedLabels("cancel"), {}, { type: 'button', "data-role": "none" }).appendTo($(this.updialog).find(".e-action-container")); 
        if (this.model.showRoundedCorner) 
            dialogActions.addClass('e-corner'); 
        this._on(dialogActions, "click", this._dialogclose); 
        if (!this.model.multipleFilesSelection) { 
            this.updialog.find(".e-ul>.e-upload-file").remove(); 
        } 
        addedFile = $("<li class='e-upload-file'></li>").appendTo(fileListDetails).data("file", files); 
        addedlist = $("<div class='e-file-list'></div>"); 
        addedfilename = $("<div class='e-file-progress e-file-view'><div class='e-file-name e-file-view'><span class='e-file-name-txt'>" + files.name + "</span></div>"); 
        addedfilebox = $("<div class='e-file-size e-file-view'><div class='e-file-box'><input class='e-filetxt' type='text' /></div>"); // creating textbox element 
        addedfilesize = $("<div class='e-file-size e-file-view'><span class='e-file-name-txt'>" +this._formatSize(0) + "\\" + this._formatSize(files.size) + "</span></div>"); 
        addedfilestatus = $("<div class='e-file-percentage e-file-view'><div class='e-file-progress-bar'><div class='e-file-progress-status'></div></div></div>"); 
        addedfileaction = $("<div class='e-action-perform'><div class='e-icon e-file-view'></div></div></div>") 
        if (this.model.customFileDetails.name) $(addedfilename).appendTo(addedlist); 
        $(addedfilebox).appendTo(addedlist); // appending to the container element 
        if (this.model.customFileDetails.size) $(addedfilesize).appendTo(addedlist); 
        if (this.model.customFileDetails.status) $(addedfilestatus).appendTo(addedlist); 
        if (this.model.customFileDetails.action) $(addedfileaction).appendTo(addedlist); 
        $(addedlist).appendTo(addedFile); 
        var dialogContainer = (this.model.dialogAction.content != null && this.model.dialogAction.content != "") ?this.model.dialogAction.content : DialogContentContainer; 
        this.updialog.ejDialog({ showOnInit: false, closeIconTooltip: this._getLocalizedLabels("closeToolTip"), minWidth: 240, width: ($(window).width() < 750) ? 250 : this._getDialogContentWidth(), height: "auto", cssClass:"e-uploadbox " + this.model.cssClass, close: $.proxy(this._uploadFileListDelete, this), enableRTL:this.model.enableRTL, target: dialogContainer, enableResize: false, allowDraggable: this.model.dialogAction.drag, enableModal: this.model.asyncUpload ? this.model.dialogAction.modal : false, showHeader:this.model.customFileDetails.title, showRoundedCorner: this.model.showRoundedCorner }) 
        $(window).width() < 750 ? $(this.updialog).closest('.e-dialog.e-uploadbox').addClass("e-mobile-upload") : $(this.updialog).closest('.e-dialog.e-uploadbox').removeClass("e-mobile-upload"); 
        me.diaObj = this.updialog.data("ejDialog"); 
        if (me.model.cssClass != "") 
            me.diaObj.setModel({ cssClass: "e-uploadbox " + this.model.cssClass }); 
        me._dialogPosition(); 
        if (this.model.showFileDetails) { 
            me.diaObj.open(); 
        } 
        this._buttonText(this.model.buttonText); 
        this._dialogText(this.model.dialogText); 
        return addedFile; 
    }; 
</script> 

 

Note:

The _pushFileDetails method can be overridden in the previous code.  Placing this code in the application will replace the default _ pushFileDetails method. The highlighted code is added in addition to the default code in the method.

 

Also, modify the existing styles to fit the textbox and apply some styling to blend the newly added text box in the Upload box’s dialog. Kindly refer to the following code snippet.

<style class="cssStyles"> 

/* Override the existing styles for the items in the dialog*/ 

    .e-uploadbox .e-head-name.e-uploadbox .e-head-status { 

        width150px; 

    } 

    .e-uploadbox .e-file-progress { 

        width130px; 

    } 

    .e-uploadbox .e-file-list .e-file-percentage { 

        width120px; 

    } 

 

/* Provide styles for newly added textbox content*/ 

    .e-uploadbox .e-file-head.e-head-box { 

        width80px; 

    } 

    .e-uploadbox .e-file-box { 

        padding-top12px; 

    } 

    .e-uploadbox .e-file-box .e-filetxt { 

        width50px; 

        border4px solid black; 

    } 

</style> 

 

Sample

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon