Telerik Forums
Kendo UI for Angular Forum
6 answers
1.1K+ views

Being a newbie to Angular 4 and typescript, I am not sure how to receive a memory stream sent back by the API controller and popup a file dialog to save it on the client.

This is what I currently have:

1) in my API controller, I am sending back an HttpResponseMessage such as:

    public HttpResponseMessage Post(ReportsManagementUI workobj)
        {

                    var zipfilename = workobj.CreateZipReport(session, sessionuser);
                    using (MemoryStream ms = new MemoryStream())
                    {
                        using (FileStream file = new FileStream(zipfilename, FileMode.Open, FileAccess.Read))
                        {
                            byte[] bytes = new byte[file.Length];
                            file.Read(bytes, 0, (int)file.Length);
                            ms.Write(bytes, 0, (int)file.Length);

                            HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
                            httpResponseMessage.Content = new ByteArrayContent(bytes.ToArray());
                            httpResponseMessage.Content.Headers.Add("x-filename", zipfilename);
                            httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
                            httpResponseMessage.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
                            httpResponseMessage.Content.Headers.ContentDisposition.FileName = zipfilename;
                            httpResponseMessage.StatusCode = HttpStatusCode.OK;
                            return httpResponseMessage;
                        }
                    }

     }

 

2) in my provider.ts, I have a function createReportsManagement which posts to the API controller code above:

public createReportsManagement(updatetype: string, reportsManagementObj: any) {
        reportsManagementObj.actiontype = updatetype;
        var headers = new Headers();
        headers.append('Content-Type', 'application/json');
        var objectToSend = JSON.stringify(reportsManagementObj);
        let apiURL = this.framework_virtual_path + "api/ReportsManagement";
        return this.http_request.post(apiURL, objectToSend, { headers: headers })
            .map(response => response.text())
            .catch(this.handleError);

}

3) On my html page, I have a component which calls  the provider to create the report zip file.

  This is where I am trying to use the KendoUI file-saver method saveAs() to popup the File Save dialog:

import { saveAs, encodeBase64 } from '@progress/kendo-file-saver';
...

 

private btnExcelClick() {
        this.reportsLoading = true;
        var responseType = 'arraybuffer';

        this.myProvider.createReportsManagement("createReport", this.reportsMgmtObj)
            .subscribe(
            (response: any) => {

                //question !!! is "data:text/plain" OK for zip file content?
                const dataURI = "data:text/plain;base64," + encodeBase64(response);
                saveAs(dataURI, "test.zip");

                //this test code works and downloads the file test.txt
                //const dataURI = "data:text/plain;base64," + encodeBase64("HELLO TEST");
                //saveAs(dataURI, "test.txt");

            } );

}

Thanks for any pointer!

 

Manuel
Top achievements
Rank 1
 answered on 28 May 2018
4 answers
3.2K+ views

Hi, 

I'm using Kendo-UI with Angular 5 and I can't figure how to implement two things : 

1. How to force focus on a Kendo-UI input element (dropDownList, TextBox, ...) which is in a kendo-window component ? I see no documentation about this. I've read that I may have to wait for the window component to trigger the activate method but such method doesn't exist in the angular version. 

2. In the grid component, how can I activate the navigation with the arrow key ? More precisely, in single selection mode, I would like the selected row to change when I press the arrow key down or up. Is this possible ? Is this possible even if I use pagination with [data] being an observable of GridDataResult ? 

Thank you in advance for your help. 

Thibaut
Top achievements
Rank 1
 answered on 28 May 2018
1 answer
2.2K+ views

Hi,

I need to display an image into Kendo Grid, and I have the path for images located in the hard-drive (not in assets folder).

How to do this?

Dimiter Madjarov
Telerik team
 answered on 28 May 2018
1 answer
3.1K+ views

 Hi,

 

I am using the Kendo UI grid for Angular and am using server-side paging. My code is paging through and retreiveing the data correctly (I have a method bound to the pageChange event on the grid) but the page number/button is not being updated (even thought I'm on page two, the button still say page one). 

 

How can I get the buttons to update correctly WITHOUT using the MVC extensions (I don't want to have an dependencies on the back end for this, it should have no idea I'm using Kendo at all).

 

Thanks,

James

James
Top achievements
Rank 2
 answered on 23 May 2018
1 answer
688 views
Is there some sample code to show a 3D pie chart with KendoUI angular 4?
Dimiter Topalov
Telerik team
 answered on 18 May 2018
3 answers
176 views

Hello, is it possible to customize message sending area in chat component.

I would like to allow users to attach files to message

Dimiter Madjarov
Telerik team
 answered on 17 May 2018
2 answers
168 views

Just started getting this in the latest update.

WARNING in ./node_modules/@progress/kendo-angular-inputs/dist/es/slider/slider.component.js
338:13-32 "export 'isDocumentAvailable' was not found in './utils'

Shawn
Top achievements
Rank 1
 answered on 15 May 2018
1 answer
2.0K+ views

Why the date-picker always empty? I tried to set the value from the typescript various way, but it always end up empty. What the right way to do it?

.ts

birthDate: new FormControl(new Date('Wed May 16 2018 00:00:00 GMT-0400')),

birthDate: new FormControl(new Date(2000, 10, 10)),

birthDate: new Date(2000, 10, 10),

.html

<kendo-datepicker formControlName="birthDate"
                          required></kendo-datepicker>

Thanks,

Bryian Tan

Georgi Krustev
Telerik team
 answered on 15 May 2018
2 answers
378 views

Hi Team,

I created the multilevel treeview using below link.

https://www.telerik.com/kendo-angular-ui/components/treeview/checkboxes/

I have requirement to search the node in the tree view till lower level node and highlight that searched node.

search should match with full text.

Please refer the attached screen shot.

 

Sankar
Top achievements
Rank 1
 answered on 14 May 2018
1 answer
261 views

I need a filter for a TreeView. A button with a textbox filter or someting like: http://dojo.telerik.com/oKIVo/29.

Question: Exist something similar for angular?

 

Thanks.

Dimiter Topalov
Telerik team
 answered on 14 May 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?