Telerik Forums
Kendo UI for jQuery Forum
3 answers
2.9K+ views
I am using Kendo File Upload for upload files and after uploading I convert the file to Byte array and save it on Database in the Binary data format. My requirement is I want to display the uploaded files(Take byte array content of files from database and the convert it into Base64 string  and pass to View using View Bag,thees section is I I did) in the uploaded area,ie the area where I upload files.
 
Code:
 
@{
    V<img src="@ViewBag.ImageData" />    @*ImageData Contain the files,taken from Dtabase
}
 
<h2>Index</h2>
 
 
@* The file Upload code,What changes are I done this code for display files in the Uploaded area ?
<div class="box">
    <p>
        File Upload Example
    </p>
</div>
<form method="post" action='@Url.Action("Save")'>
    <div class="demo-section k-content">
 
         <h6>Upload Attachments</h6>
 
        @(Html.Kendo().Upload()
    .Name("files").
    TemplateId("fileTemplate")
    .Messages(m => m.Select("Add files here."))
    .Async(a => a
        .Save("Save", "Upload")
        .Remove("Remove", "Upload")
        .AutoUpload(false)).Events(events => events.Select("onSelect")))
        
 
        
        <script id="fileTemplate" type="text/x-kendo-template">
            <span class='k-progress'></span>
            <div class='file-wrapper'>
                <img class='file-icon #=addExtensionClass(files[0].extension)#' /> <!-- here im trying to bind the image -->
                @*<h4 class='file-heading file-name-heading'>Name: #=name#</h4>
                    <h4 class='file-heading file-size-heading'>Size: #=size# bytes</h4>*@
                <button type='button' class='k-upload-action'></button>
            </div>
        </script>
 
        <script>
    var a = 0;
    function onSelect(e) {
        $.each(e.files, function (index, value) {
            readMultipleFiles(value);
        });
        a++;
    }
 
    function addExtensionClass(extension) {
        return a;
    }
 
 
    function readMultipleFiles(file) {
        var reader = new FileReader();
        reader.onload = function (e) {
            // bind the file content
            $('.'+a+'').attr({ src: e.target.result });
        }
        reader.readAsDataURL(file.rawFile);
    }
 
 
        </script>
 
        <style scoped>
            .demo-section{
                width: 350px;
                float: right;
                background-color: #f7f7f7;
                padding: 20px;
                border: 1px solid #dbdbdb;
            }
 
            .demo-section .k-widget.k-upload.k-header{
                border-radius: 0px;
                border: none;
                background-color: #F7F7F7;
            }
 
            .demo-section .k-upload-files{
                width: 100%;
                overflow: hidden;
                background-color: #fff;
                border: none;
                min-height: 235px;
            }
 
            .demo-section .k-upload-files .k-file{
                width: 48%;
                float: left;
                border: none;
                padding-left: 0px;
            }
 
            .demo-section .k-dropzone{
                background-color: #fff;
                border-bottom: none;
                margin-bottom: 30px;
            }
 
           .demo-section .k-dropzone .k-button.k-upload-button{
                height: 75px;
                border: 1px dashed #000;
                width: 100%;
                background-color: #fff;
                border-radius: 0px;
                padding-top: 26px;
                background-position: 0px;
                box-shadow: none;
           }
 
           .demo-section .k-dropzone .k-button.k-upload-button input{
               background-color: #fff;
               box-shadow: none;
           }
 
            .file-icon {
                /*display: inline-block;
                float: left;
                width: 80px;
                height: 80px;
                margin-left: 42px;
                margin-top: 45.5px;*/
                width: auto;
                height: 135px;
                max-height: 100%;
                max-width: 100%;
            }
 
            li.k-file .file-wrapper .k-upload-action {
                position: absolute;
                top: 0;
                right:0;
            }
 
            li.k-file div.file-wrapper {
                position: relative;
                height: 100px;
                padding: 15px;
 
                /*float:left;
                width:50%;*/
            }
        </style>
 
    </div>
 
 
</form>
Veselin Tsvetanov
Telerik team
 answered on 05 Nov 2019
13 answers
974 views

Is there a solution to that allows users to drag and drop both a file and folder at the same time?

If not, is there a workaround to drop files and folders independently into the same drop zone. Currently, have a half-backed solution that changes the options.directoryDrop on the drop event, but only works on the second drop attempt. The timing of setting the option seems to be too late.

 

 $("#files").kendoUpload({
                    async: {
                        saveUrl: "/document/upload",
                        autoUpload: true
                    },
                    directoryDrop: true,
                    dropZone: ".dropZone"
                });

 

                $(".dropZone").on("drop", function (e) {
                    e.preventDefault();
                    e.stopPropagation();
                    var isFolder = false;
                    var files = e.originalEvent.dataTransfer.files;

                    // find at least one folder in dropped files

                    $.each(files, function (i,file) {

                        // folders are identified with no extension and segment size of 4096
                        if (!file.type && file.size % 4096 === 0)  isFolder = true;
                    });

                    $("#files").data("kendoUpload").options.directoryDrop = isFolder;
                });

 

Dimitar
Telerik team
 answered on 05 Nov 2019
2 answers
311 views

Hi

I'm having a problem with a detail template in combination to reorderable columns.

Because I want to reorder and save and load the state, the internet solution was to do this myself.
This is in the row-template and the getRowTemplate function.

But while doing this, there seems to be a problem when using a detail template.
Just expand detail template in exmple below and console will throw "Cannot convert undefined or null to object".

http://dojo.telerik.com/uMUluKUj/5

Greets Robin

Robin
Top achievements
Rank 1
 answered on 04 Nov 2019
2 answers
426 views

This occurs even in the masked textbox API demo.

 

On Page load the markup looks like this:

<span class="k-widget k-maskedtextbox" style="width: 100%;">
 <input id="maskedtextbox" name="maskedtextbox" style="width: 100%" data-role="maskedtextbox" class="k-textbox" autocomplete="off"><span class="k-icon k-i-warning">
</span>
</span>
<script>kendo.syncReady(function(){jQuery("#maskedtextbox").kendoMaskedTextBox({"mask":"(999) 000-0000","rules":{}});});</script>

 

The mask works.

If you click the Readonly button the markup changes to this:

<span class="k-widget k-maskedtextbox" style="width: 100%;">
<input id="maskedtextbox" name="maskedtextbox" style="width: 100%" data-role="maskedtextbox" class="k-textbox" autocomplete="off" readonly="readonly">
<span class="k-icon k-i-warning"></span></span>
<script>kendo.syncReady(function(){jQuery("#maskedtextbox").kendoMaskedTextBox({"mask":"(999) 000-0000","rules":{}});});</script>

 

The only apparent difference is the addition of the readonly attribute.

 

If I remove the readonly attribute.  I can type in the textbox again, but it doesn't follow the mask.

 

 

 

 

 

 

 

Boyan Dimitrov
Telerik team
 answered on 04 Nov 2019
3 answers
78 views

Hello,

Grid Search Panel call read data when focus and lost focus of search field in IE browser. 

There: https://demos.telerik.com/kendo-ui/grid/search-panel

Not expected behavior in IE:

1. Click to search panel, changed page to first.

2. Click to second page (when focus in search panel), then it load second page then load first page

 

Tsvetomir
Telerik team
 answered on 04 Nov 2019
6 answers
551 views

There is a graph in which the date and sent to different values, the values can be both positive and negative.
In advance it is not known what it is understandable, we must first of all to sort data, time-consuming
Is there any comprehensive solution to display the date at the bottom of the graphs (categoryAxis.categories)?

________________

 
Есть график, в который отправляются даты и различные значения, значения могут быть как отрицательные так и положительные.
Заранее это не известно, что бы это понятно , надо предварительно производить сортировку всех данных,  что трудоемко
Существует ли какое-нибудь универсальное решение выводить даты  внизу графиков(categoryAxis.categories), как для положительных так и для отрицательных значений?

 

Tsvetomir
Telerik team
 answered on 04 Nov 2019
1 answer
337 views

We use chunk upload of files to send large files asynchronously with multiple requests.

I want to add custom field to each request (for example File ID) using e.data property.

This custom field has one-to-one relation (file ID <-> file).

 

I found out property -> e.files is Array (A list of the files that will be uploaded).

It means that upload event be triggered for multiple files.

 

I can`t understand cases when this field may contain more than one record (for async mode, using chunks).

On the server side -> request contains such info as chunkIndex, fileName, totalFileSize....

It means: one request for one file.

 

My questions are:

1. When do the upload event may have files property with more than one record?

2. Сan I rely on the fact that "files.length = 1" for async mode using chunks.

3. Is there are any other options to add my custom field (belongs to file) to request?

 

I really hope for your help, thanks.

Veselin Tsvetanov
Telerik team
 answered on 04 Nov 2019
1 answer
4.2K+ views
Hello

I'm using kendoUI multiselect, but have some issues with the styling - The input field is smaller than the surrounding div causing it to look weird. Also the data-placeholder text is only shown partially until the first time the controle is clicked

I'm using FuelUx  2.3.0, Twitter Bootstrap 2.3.2, jQuery 1.10.2 and KendoUI v2013.2.716

Here is my source code using the MultiSelect:

01.<!DOCTYPE html>
02.<html lang="en" class="fuelux">
03.  <head>
04.    <meta charset="utf-8">
05.    <script src='http://localhost/shared/assets/js/jquery-1.10.2.min.js' type='text/javascript'></script>
06.    <link rel='stylesheet' type='text/css' href='http://localhost/shared/assets/css/smoothness/jquery-ui-1.8.17.custom.css'>
07.    <script src='http://localhost/shared/assets/js/jquery-ui-1.9.1.custom.min.js' type='text/javascript'></script>
08.    <link rel='stylesheet' type='text/css' href='http://localhost/shared/assets/css/KendoUI/kendo.common.min.css'>
09.    <link rel='stylesheet' type='text/css' href='http://localhost/shared/assets/css/KendoUI/kendo.default.min.css'>
10.    <script src='http://localhost/shared/assets/js/KendoUI/src/kendo.web.js' type='text/javascript'></script>
11.    <script src="http://localhost/shared/assets/js/loader.js"></script>
12.    <link href="http://localhost/shared/assets/css/fuelux.css" rel="stylesheet">
13.  </head>
14.  <body>
15.    <script type='text/javascript'>
16.      var gVars = {};
17.      gVars.conf = {foo:'bar'};
18.      gVars.mainEventModel = {foo:'bar'};
19.      $(function(){
20.        gVars.objDetailsPage = new gVars.detailsPage(gVars.mainEventModel,1);
21.        gVars.objDetailsPage.selectArea();
22.      });
23.    </script>
24. 
25.    <script type="text/x-kendo-template" id="selectAreaTemplate">
26.      <label class = "control-label" for="treatedArea">Treated area:</label>
27.      <div class = "controls">
28.        <input id="treatedArea" style="width:400px;height:50px;"
29.               data-role="multiselect"
30.               data-auto-bind="true"
31.               data-placeholder="Click to select ..."
32.               data-text-field="name"
33.               data-value-field="value"
34.               data-source="gVars.objDetailsPage.getEventParameterTypeDataSource(13)" />
35.      </div>
36.    </script>
37. 
38.    <script type='text/javascript'>
39.      gVars.detailsPage = function(mainEventModel,treatmentTypeId) {
40.        this.treatmentTypeId = treatmentTypeId;
41.        this.mainEventModel = mainEventModel;
42.        this.eventParameterTypes = {
43.          overallResult : 1,
44.          treatment : 8,
45.          treatedArea : 13
46.        };
47.      };
48. 
49.      gVars.detailsPage.prototype.getEventParameterTypeDataSource = function(eventParameterId) {
50.        var dataSrc = new kendo.data.DataSource({
51.          transport: {
52.            read: {
53.              url: gVars.conf.getParameterTypeData,
54.              dataType: "json",
55.              data : {
56.                eventParameterTypeId : eventParameterId
57.              }
58.            }
59.          }
60.        });
61.        return dataSrc;
62.      };
63. 
64.      gVars.detailsPage.prototype.selectArea = function(){
65.        var diversForm = new kendo.View('selectAreaTemplate');
68.        var html = diversForm.render();
69.        $('#TemplateArea').html(html);
70.
      };
79. 
80.    </script>
81.    <div id="TemplateArea"></div>
82.  </body>
83.</html>
And here is the generated Markup (taken from Firefox, firebug console)
01.<div>
02.  <label class="control-label" for="treatedArea">Treated area:</label>
03.  <div class="controls">
04.    <div class="k-widget k-multiselect k-header" style="width: 400px; height: 50px;">
05.      <div class="k-multiselect-wrap k-floatwrap">
06.        <ul id="treatedArea_taglist" class="k-reset" unselectable="on" role="listbox">
07.          <input class="k-input" style="width: 25px" accesskey="" role="listbox" aria-expanded="false" tabindex="0" aria-owns="treatedArea_taglist treatedArea_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false">
08.          <span class="k-icon k-loading k-loading-hidden"></span>
09.      </div><input id="treatedArea" data-source="gVars.objDetailsPage.getEventParameterTypeDataSource(gVars.objDetailsPage.eventParameterTypes.treatedArea)" data-value-field="value" data-text-field="name" data-placeholder="Click to select ..." data-auto-bind="true" data-role="multiselect" style="width: 400px; height: 50px; display: none;" multiple="multiple" aria-disabled="false" aria-readonly="false">
10.      <option value="0">Boot top</option>
11.      <option value="1">Upper verticals</option>
12.      <option value="2">Lower verticals</option>
13.      <option value="3">Entire verticals</option>
14.      <option value="4">Flat bottom</option>
15.      <option value="5">Entire hull</option>
16.      </input>
17.      <span style="font-family: MS Shell Dlg; font-size: 13.3333px; font-stretch: normal; font-style:normal; font-weight: 400; letter-spacing: normal; text-transform: none; line-height: 16px; position: absolute; visibility: hidden;"></span>
18.    </div>
19.  </div>
20.</div>

Smita
Top achievements
Rank 1
 answered on 04 Nov 2019
1 answer
6.5K+ views

Hi there,

I have a multi select dropdown. I was able to get the selected items list - which has the list of id's. But I wanted to pull the list of selected items text, instead of id's? Can someone help me out please?

 

Ex: MULTISLECT Dropdown

    Id Value

  1    ABC

  2  XYZ

  3  IJK

If 1 and 2 are selected, I wanted the values [ABC, XYZ], instead of [1,2].

 

Appreciate your help.

 

Kind Regards

NeelimaN

Smita
Top achievements
Rank 1
 answered on 04 Nov 2019
2 answers
527 views
Hey!

I have a simple drop down list bound to a kendo.observable object, I'm having difficulty implementing a template for the drop down.

I've tried several methods found online but can't seem to get it to work

example of code structure:
http://jsfiddle.net/hLG98/24/
jan
Top achievements
Rank 1
 answered on 02 Nov 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?