Telerik Forums
UI for ASP.NET MVC Forum
1 answer
95 views

hi everybody,

I have this grid that works well, and pass the id=0 when clicking on the icon, unfortunately I can't find away to pass the hidden ID value.

is there something I am missing here.

I appreciate any help from you guys

regards, Ray

@(Html.Kendo().Grid<HeatersLibrary.Models.DocumentsViewModel>
    ()
    .Name("grid")
    .Columns(columns => {
        columns.Bound(p => p.ID).Hidden();
        columns.Bound(p => p.Brand);
        columns.Bound(p => p.Size);
        columns.Bound(p => p.Type);
        columns.Bound(p => p.PartNumber);
        columns.Bound(p => p.Filename);
        columns.Bound(p => p.Description);
        columns.Bound(null).Title(" ").Width(50)
        .ClientTemplate(
            @Html.ActionLink(" ", "EditDoc", "Home", new { id=0 }, htmlAttributes: new { @class = "glyphicon glyphicon-pencil", @title = "Edit Description" }).ToHtmlString() + " | " +
            @Html.ActionLink(" ", "DeleteDoc", "Home", new { id=0 }, htmlAttributes: new { @class = "glyphicon glyphicon-trash", @title = "Delete Description \n WITHOUT CONFIRMATION" }).ToHtmlString()
            )
        ;

    })
    .Pageable()
    .Scrollable()
    .HtmlAttributes(new { style = "height:250px;" })
    .DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(10)
    .Read(read => read.Action("BindingDocuments", "Home").Data("additionalData"))
    )
    )

Raymond
Top achievements
Rank 1
Veteran
Iron
 answered on 18 Oct 2024
1 answer
45 views

https://www.telerik.com/forums/setoptions-clearing-the-toolbar

I found the above forum thread with a solution/sample link to github but that page no longer exists (HTTP 404). Where can I find the sample now? or else, is there an alternative solution introduced in past 3 years?

Eyup
Telerik team
 answered on 18 Oct 2024
1 answer
157 views
Hello,

I am currently working with a Kendo Grid in my ASP.NET MVC application, specifically with a foreign key column that retrieves its data from a separate data source. I have enabled filtering on this grid, and I would like to implement a "contains" filter for a foreign key column, specifically for the "Locations" column.

Here’s the relevant portion of my Kendo Grid configuration:
            @(
                Html.Kendo().Grid<FMS_Cloud_CoreMVC.ViewModels.EnergyAdmin>()
                            .Name("EAData")
                            .Filterable()
                            .Columns(
                            
                            columns =>
                            {
                                columns.ForeignKey(p => p.CompLocID, ds => ds.Read("GetLocations", "EnergyAdmin"), "CompLocID", "CompLocString")
                                .Title("Locations").Width(300)
                                .Filterable(ftb => ftb.Cell(cell =>
                                    cell.Operator("contains").SuggestionOperator(FilterType.Contains)));





                    columns.ForeignKey( p => p.Provider, ds => ds.Read( "GetEnergyProviders", "EnergyAdmin"), "DDLID", "ProviderName")
                    .Title("Provider").Width(150) ;
                               
                    columns.Bound(p => p.NMI).Width(150);
                    columns.Bound(p => p.WWDeviceId).Width(150);
                   

                    columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); }).Width(200);
                })
                .ToolBar(toolbar => toolbar.Create())
                .Editable(editable => editable.Mode(GridEditMode.InLine))
                .Pageable()
                .Sortable()
                .Scrollable()
                .HtmlAttributes(new { style = "height:730px;" })
                .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .Events(events => events.Error("error_handler"))
                .Model(model => model.Id(p => p.EnergyAdminId))
                .Create(update => update.Action("EditingInline_Create", "EnergyAdmin"))
                    .Read(read => read.Action("EditingInline_Read", "EnergyAdmin").Data("myCustomReadParam"))
                .Update(update => update.Action("EditingInline_Update", "EnergyAdmin"))
                .Destroy(update => update.Action("EditingInline_Destroy", "EnergyAdmin"))
                )
                )





While the "contains" filter works as expected with a simple text column, I would like to maintain the dropdown functionality for the foreign key column. Is there a way to achieve a "contains" filter on a foreign key column while still allowing users to select from the dropdown options?

I would greatly appreciate any guidance or examples you can provide.

Thank you in advance for your assistance!
Eyup
Telerik team
 answered on 14 Oct 2024
1 answer
81 views

Hi, I've got a grid whose rows expand to show another, templated, grid. I also have clickable links in the cells of the parent grid. Using a mouse, I can click these links directly or click the expansion icon to expand the row. Using keyboard navigation, however, I can only expand the parent row when I press enter. On grids without a templated sub-grid, pressing Enter will focus the link in the parent cell. I would like this behavior to be uniform.

I have tried intercepting the keydown event, but it seems that the expansion occurs even when I try to prevent default or return false as it happens seemingly in parallel.

Is there a way to achieve the functionality I want without resorting to overriding keydown or, if not, is there a way to cancel/control the expansion myself rather than having it automatically happen so that I can handle it in a custom keydown?

Grid example:

On this grid, when I press enter while Dialog Link column cell is selected, it expands the row.

Here in this example is a grid without a templated subgrid. Pressing enter on the same column focuses the "AAA" anchor tag within it, which is the desired behavior in both grids.

My attempt to control the expansion myself via a custom keydown event. The expansion happens before this logic has a chance to finish running:

Eyup
Telerik team
 answered on 07 Oct 2024
1 answer
127 views

I have a datepicker in a view 

@(Html.DatePickerFor(model => model.EventDate)
     .Format("{0:dd/MM/yy}")
)

I need to retrieve the date from the datepicker to use as the minimum value for a datetimepicker in a list view. 


		shiftStart.kendoDateTimePicker({
			timeFormat: "HH:mm",
			format: "dd/MM/yyyy HH:mm",
			// min: new Date(vYear, vMonth - 1, vDay, vHour, vMinute),
			interval: { minutes: 15 }
		});

How do I get that value?

Ivan Danchev
Telerik team
 answered on 03 Oct 2024
2 answers
57 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
66 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
64 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
53 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
328 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
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?