Telerik Forums
UI for ASP.NET MVC Forum
2 answers
49 views

I have an image editor with a button, when the button is pressed it saves the image to a folder on the server. 

It works in most cases, although sometimes it throws an Http 400 error. 

How do I add error handling so I can present a nice message to the user?

It seems the error happens when the image size (height and/or width) is exceptionally big, is that the case? 

here's my code:


    <form method="post">
      <input type="hidden" asp-for="editedFileName" />
      <input type="hidden" asp-for="ImagePath" />
      <div class="admin-button-container align-right">
        <button type="submit" class="btn btn-theme-admin">Save Image</button>
      </div>
      <div class="imageEditor"></div>
    </form>

my js:


$(document).ready(function() {
	var OpenExecuted = false;
	//  page load
	showImgOption();
});


function onSelect(e) {
	$('#editedFileName').val(e.files[0].name);
}

function handleUploadImageEvents(imageEditor) {
	OpenExecuted = true;
	imageEditor._upload.bind("select", onSelect);
}

function onImageRendered(e) {
	zoom();
	saveImagePath();
};

function onExecute(e) {
	if (e.command === "OpenImageEditorCommand") {
		setTimeout(function() {
			handleUploadImageEvents(e.sender);
		});
	}
};

// this function will zoom out the photo if the height is more than 600px 
// so that it does not overlap other fields on the page
function zoom() {
	var imgEditor = $('.imageEditor').data('kendoImageEditor');

	imgEditor.executeCommand({ command: "ZoomImageEditorCommand", options: imgEditor.zoom = 1 });
	var imgHt = $(".k-imageeditor-canvas").height();
	if (imgHt > 600) {
		imgEditor.executeCommand({ command: "ZoomImageEditorCommand", options: imgEditor.getZoomLevel() - 0.5 });
	}
};


function ImgEditor() {
	$(`.imageEditor`).kendoImageEditor({
		toolbar: {
			items: [
				"open",
				"save",
				"crop",
				"resize",
				"undo",
				"redo",
				"zoomIn",
				"zoomOut",
				"zoomDropdown",
			]

		},
		messages: {
			toolbar: {
				open: "Upload"
			},
		},
		imageUrl: $('[id="ImagePath"]').val(),
		height: 650,
		error: onError,
		imageRendered: onImageRendered,
		execute: onExecute,
	});
}



function onError(e) {
	console.log('Error');
};

function showImgOption() {
	var imgFilePath = $('[id="ImagePath"]').val();
	if (imgFilePath.length > 0) {
		var imgFilename = imgFilePath.slice(imgFilePath.lastIndexOf("/") + 1, imgFilePath.length + 1);
		$('[id="FileName"]').val(imgFilename);
	}

		ImgEditor();
}


function saveImagePath() {
	const imageEditor = $('.imageEditor').data('kendoImageEditor');
	const image = imageEditor.getCurrentImage();
	const imageObject = new DOMParser().parseFromString(image, "text/xml");
	const canvas = imageEditor.getCanvasElement();
	const fileArray = canvas.toDataURL().split(",");
	const base64String = canvas.toDataURL();
	const imagePathSaved = $('[id="ImagePath"]').val(fileArray[1]);
}


Lindsay
Top achievements
Rank 1
Iron
 answered on 01 Oct 2024
2 answers
49 views

Hi Team,

We've noticed a problem where the "Items per page" section of the grid doesn't load at first. As observed below.

After the screen is zoomed out, it is visible.

Explanation of scenario-

Screen is in default zoom 100% - Not visible, once zoomed out to any value below 100% say 90 - Visible

Screen loaded in 90% - Not visible, Once zoomed out below 90 - Visible

Vijay
Top achievements
Rank 1
Iron
 answered on 01 Oct 2024
1 answer
56 views

Hello,

in our grid we have a ForeignKey-column to show the Text of a dropodown instead of the Value (see discussion here: https://www.telerik.com/forums/telerik-mvc-grid---show-selectlistitem-text-instead-of-value):

columns.ForeignKey(c => c.STATUS, Helper.IDTB_PRUEFUNG.Dropdowns.Status, "Value", "Text");

This is the corresponding dropdown:

public class Dropdowns
{
    public static List<SelectListItem> Status
    {
        get
        {
            return new List<SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "New",
                    Value = "NEU",
                    Selected = true
                },                
                new SelectListItem()
                {
                    Text = "Locked",
                    Value = "GESPERRT"
                }
            };
        }
    }
}

The Read-Action on the server is fairly simple:

[AcceptVerbs(HttpVerbs.Post)]
public JsonResult Read([DataSourceRequest] DataSourceRequest request, int lot_id)
{
    var pruefungen = db.IDTB_PRÜFUNG.Where(p => p.LOT_ID == lot_id);

    return Json(pruefungen.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

Now when we sort this column, the sorting is applied on the Value. I assume this is because the sorting is done on the database level? (We use Entity Framework here.)

Is there a way to have the sorting applied on the Text instead of the Value?

(I am aware that this is asking for a bit of magic here, since the database only knows about the Value and knows nothing about the Text. So I would even be happy for some hints in the a general direction to solving this (maybe client-side sorting, or sth. else). :) )

Eyup
Telerik team
 answered on 28 Sep 2024
1 answer
43 views

column.Bound(x => x.ReportUrl).ClientTemplate("<a href='#= ReportUrl #' target='_blank'>#= ReportUrl #</a>").Width(100);

Can I use a ClientTemplate to invoke a method from my controller when I click on the record in grid? 

Maybe there is some examples?

Mihaela
Telerik team
 answered on 25 Sep 2024
2 answers
261 views
Hi ,

I have migrated my MVC project from .net framework 4.8 to .net 8.0. This need me to install KendoUICore package. Earlier i was using 
Kendo.Mvc.dll

I'm not finding any relevant documents to fix the error related to Kendo 
Error (active) CS0246 The type or namespace name 'DataSourceRequest' could not be found (are you missing a using directive or an assembly reference?)
Error (active) CS0246 The type or namespace name 'DataSourceRequestAttribute' could not be found (are you missing a using directive or an assembly reference?)
Error (active) CS0246 The type or namespace name 'ContextMenuItem' could not be found (are you missing a using directive or an assembly reference?)
Error (active) CS0246 The type or namespace name 'MenuItem' could not be found (are you missing a using directive or an assembly reference?)

Issue is there in all the controls, I'm not able to compile my application.. Added few errors above

Need help on how to migrate from Kendo.Mvc to KendoUICore in ASP.Net MVC project with .net 8.0 as target framework
Renu
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 24 Sep 2024
1 answer
50 views

 

I have PanelBar called  Interest Rates and 3 children. I want the parent and all the 3 children cursor to  pointer when hover the mouse.

Interest Rates

Default Rates

Negative Carry

Cash FTP

 

Thanks,

Abdul Ashad

Eyup
Telerik team
 answered on 17 Sep 2024
1 answer
81 views

We want to use the DatePicker like this:

<div class="row">
    <div class="col">
        <div class="form-group">
            @Html.LabelFor(model => model.TESTDATUM, htmlAttributes: new { @class = "control-label" })
            <div>
                @Html.Kendo().DatePickerFor(model => model.TESTDATUM)
                @Html.ValidationMessageFor(model => model.TESTDATUM, "", new { @class = "text-danger" })
            </div>
        </div>
    </div>
</div>

But this renders the control like this:

We're currently using the following workaround to trim the overlapping part, which feels kind of 'hacky':


<div style="width: 17.5em">
    @Html.Kendo().DatePickerFor(model => model.TESTDATUM)
</div>
Is there a better/cleaner way to have the control to render correctly (with Bootstrap)?
Aleksandar
Telerik team
 answered on 16 Sep 2024
1 answer
54 views

How to make the Kendo Panel Bar children as right indented.

 

For example I have PanelBar called  Interest Rates and 3 children. I want the 3 children as below right indented.

 

Interest Rates

Default Rates

Negative Carry

Cash FTP

 

Thanks

Abdul Ashad

 

 

Tsvetomila
Telerik team
 answered on 12 Sep 2024
1 answer
79 views

Hello,

we have some dropdown fields (List<SelectListItem>) for which we would like to show the SelectListItem-Text (instead of Value) in the grid.

The grid is NOT in edit mode.

The column renders as 'undefined':

(Info: if we switch to edit-mode in the grid, the dropdown is working correctly, it's just the display of the Text in the cell that's not working.)

How do we need to configure this?

 

This ist the List<SelectListItem>:

public class Dropdowns
{        
    public static List<SelectListItem> Status
    {
        get
        {
            return new List<SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = Resource.ACTIVE,
                    Value = "Aktiv"
                },
                new SelectListItem()
                {
                    Text = Resource.DELETED,
                    Value = "Gelöscht"
                },
                new SelectListItem()
                {
                    Text = Resource.EXPIRED,
                    Value = "Ausgelaufen"
                }
            };
        }
    }
}

This is the field in the model:

[Required]
[UIHint("STATUSEditor")]        
[Display(Name = "STATUS", ResourceType = typeof(Resource))]
public string STATUS { get; set; }

This is the editor template:


@using Kendo.Mvc.UI
@model Models.IDTB_CHARGE

@(
Html.Kendo().DropDownListFor(m => m.STATUS)
    .Name("STATUS")
    .DataValueField("Value")
    .DataTextField("Text")
    .ValuePrimitive(true)    
    .BindTo(Areas.Chargen.Helper.Dropdowns.Status)
)

This is the column in the grid:

 columns.Bound(c => c.STATUS).ClientTemplate("#=STATUS.Text#").Width(130);

Mihaela
Telerik team
 answered on 11 Sep 2024
1 answer
45 views

Hi,

 

I am trying to know if telerik offers to extract the selected text and its coordinates using JQuery PDFViewer control?

If yes, anyone please share the examples?

Alexander
Telerik team
 answered on 06 Sep 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?