Telerik Forums
Kendo UI for jQuery Forum
1 answer
554 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>
Dimiter Madjarov
Telerik team
 answered on 11 Aug 2016
1 answer
421 views

 have a kendo grid(with pagination Enabled) with some entries. Say, I have 5 pages and I have selected(clicked on checkbox) one row from each page and then clicked on top level action DELETE. I am not able to figure out how to delete the entries from the grid and the data source?
I tried below code, which deletes the entries from the page which is visible in the grid (on screen)

var grid = $("#grid").data("kendoGrid");
var userSelectionInfo = usersService.getUserSelectionInfo();
 
for(var userName in userSelectionInfo) {
    if(userSelectionInfo[userName]) {
            var selector = '#' + userName+ '_actions';                
            grid.removeRow($(selector).closest('tr'));
     }
}

I tried one more approach:
I created an array of objects which will remain after deletion operation from the original array of objects and then added into the grid data source.

var newData = [];
var userSelectionInfo = usersService.getUserSelectionInfo();
for(var i = 0; i < users.length; i++) {
        if(users[i].userName&& !userSelectionInfo[users[i].userName]) {            
              newData.push(users[i]);
        }
}    
loadUsersIntoGrid(newData);
Is there any better approach or kendo API which I am missing? Thanks in advance.

Stefan
Telerik team
 answered on 11 Aug 2016
1 answer
206 views

Hi all, 

 

I have a custom form in my scheduler, and after one event is submitted, the recurrence editor does not reset. It holds, displays, and uses the previously entered recurrence data. What is the best way to manually achieve a recurrence editor reset? I couldn't find any information in the scheduler documentation about programatically editing the contents of the recurrence editor.

 

Thanks.

Vladimir Iliev
Telerik team
 answered on 11 Aug 2016
1 answer
113 views

This is regarding an issue that we are facing with combo box column sorting , if we bind a string fields as “DatavalueField “ and do sorting on Combo box column Kendo grid binding is braking. But this works if we bind numeric field with DatavalueField and it sorts with this field. But in our case we need to sort by the field bound to DataTextField (which is in the UI). Please suggest possible solution or work around to address this issue.

Looking forward to hear from you soon - thanks in advance.

Georgi Krustev
Telerik team
 answered on 11 Aug 2016
1 answer
269 views

This is regarding an issue that we are facing with combo box column sorting , if we bind a string fields as “DatavalueField “ and do sorting on Combo box column Kendo grid binding is braking. But this works if we bind numeric field with DatavalueField and it sorts with this field. But in our case we need to sort by the field bound to DataTextField (which is in the UI). Please suggest possible solution or work around to address this issue.

Looking forward to hear from you soon - thanks in advance.

Georgi Krustev
Telerik team
 answered on 11 Aug 2016
1 answer
8.3K+ views
I want to be able to dynamically set the column headers. The title attribute of the columns is not sufficient, see below:
 columns: [
            { field: "CustomerNumber", title: "Customer Number", attributes: { style: "white-space: nowrap" } },
            { field: "CustomerName", title: "Customer", attributes: { style: "white-space: nowrap" } },
            { field: "InvitationEmail", title: "Email", template: "<a href=\"mailto:#=InvitationEmail#\">#=InvitationEmail#</a>", attributes: { style: "white-space: nowrap" }},
        ]

How do I set the title dynamically? These values typically come from the resource file.
Vladimir Iliev
Telerik team
 answered on 11 Aug 2016
4 answers
919 views
Hello,

I've tried

.
.
.
            schema: {
                type: "json",
                model: {
                    id: "id",
                    fields: {
                        c_pmchart: {type: "string", validation: { required: true }},
                        defi: { type: "string", validation: { required: false }, defaultValue: function () {return 'test value';} },
.
.
.

to set a field's defaultValue via an anonymous function but it di not work. Any ideas how to set deafultValues by a function  ?

TIA
Nikolay Rusev
Telerik team
 answered on 11 Aug 2016
3 answers
106 views

I am using an Event Template that does not have the end datetime visible to the end user. The actual end datetime is calculated based on other dropdown selections made which give a duration for the task that is then added to the start datetime.

The event creation works fine but initially the event block only occupies the default slot for the view (e.g. 30mins for the day, week views). If I change the view (advance a day say) and then return back the block now correctly occupies the time slots associated with its start/end datetimes.

How can I get the scheduler to redraw the block when created?

Vladimir Iliev
Telerik team
 answered on 11 Aug 2016
4 answers
271 views
I saw on this thread the solution to the grouping problem when using row template by using jQuery $.proxy

Now i have my grid with MVVM binding. Is it possible to use $.proxy in data-row-template?

Here's a simplified fiddle of my code: http://jsfiddle.net/MhWVn/2/


Vladimir Iliev
Telerik team
 answered on 11 Aug 2016
1 answer
141 views

when the scheduler is in "mobile" mode, e.g. the view selector goes from buttons to a single dropdown, whenever you click the dropdown, it calls my navigate and paramterMap function and calls the read api. Then when i select the new view it calls again. All calls have the correct date ranges.

how do i get stop the first call from occurring? e.g. it is making 2 calls every time. The second call is the correct call. The first call is essentially re-calling the initialization script or pulling in the same data it already has loaded.

 

code snippet

 

            $("#scheduler").kendoScheduler({
                toolbar: ["pdf"],
                pdf: {
                    fileName: "My_School_Year_Calendar.pdf",
                    proxyURL: "//demos.telerik.com/kendo-ui/service/export"
                },
                startTime: today,
                date: today,
                timezone: "",
                allDayEventTemplate: adTemplate,
                eventTemplate: eTemplate,
                views: [
                    { type: "agenda", selected: true },
                    "day",
                    "week",
                    "month"
                ],
                editable: false,
                dataBound: scheduler_dataBound,
                dataSource: {
                    transport: {
                        read: {
                            url: "@Url.Action("Calendar", "Homeroom")",
                            dataType: "json",
                            contentType: "application/json; charset=utf-8",
                            type: "POST"
                        },
                        parameterMap: function (options, operation) {

                            if (operation === "read") {
                                var scheduler = $("#scheduler").data("kendoScheduler");

                                var result = {
                                    start: scheduler.view().startDate().toMsyString(),
                                    end: scheduler.view().endDate().toMsyString()
                                };
                                return kendo.stringify(result);
                            }
                            return kendo.stringify(options);
                        }
                    },
                    serverFiltering: true,
                    schema: {
                        model: {
                            id: "taskID",
                            fields: {
                                classId: { from: "ClassId", type: "number" },
                                taskID: { from: "TaskID", type: "number" },
                                title: { from: "Title", defaultValue: "No title", validation: { required: true } },
                                start: { type: "date", from: "Start" },
                                end: { type: "date", from: "End" },
                                ownerId: { from: "StudentId", defaultValue: 1 },
                                isAllDay: { type: "boolean", from: "IsAllDay" }
                            }
                        }
                    }
                },
                filter: {
                    logic: "or",
                    filters: [
                        { field: "ownerId", operator: "eq", value: 513 },
                        { field: "ownerId", operator: "eq", value: 531 }
                    ]
                },
                resources: [
                    {
                        field: "ownerId",
                        title: "Student",
                        dataSource: [
                            @Html.Raw(@Model.Sources.StudentResourceJs)
                        ]
                    }
                ],
                change: function (e) {
                    var start = e.start;
                    var end = e.end;

                    console.log(kendo.format("Selection between {0:g} and {1:g}", start, end));
                },
                navigate: function (e) {
                    console.log("navigate", e.date);
                }
            });

Robert
Top achievements
Rank 1
 answered on 10 Aug 2016
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Map
Drag and Drop
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
PivotGridV2
Licensing
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?