Telerik Forums
UI for ASP.NET Core Forum
1 answer
1.2K+ views

On the post back from a razor page I am expecting the SelectedIndex to set a value for me. but it is always 0.

How do I get it to set the selectedindex? 

@(Html.Kendo().DropDownListFor(m => m.Contractor)        
        .SelectedIndex(Model.Contractor.CompanyId)
        .DataTextField("Text")
        .DataValueField("Id")
        .OptionLabel("Please select")
        .BindTo(ViewBag.CompanyId)
        )

Also tried:

@(Html.Kendo().DropDownListFor(m => m.Contractor)        
        .SelectedIndex(Model.LocationIdSelected)
        .DataTextField("Text")
        .DataValueField("Id")
        .OptionLabel("Please select")
        .BindTo(ViewBag.CompanyId)
        )
Aleksandar
Telerik team
 updated answer on 11 Oct 2021
1 answer
371 views

Hy,

is there a way to set the focus on the search panel when page is ready?

I already tried this but the focus is set automaticilly to --> see image.

I saw that the k.input class is in every filterable column.  

This is my code:
@(Html.Kendo().Grid<LLTelefonliste.Models.TelefonUndAbwesendGmbHKg>()
                    .Name("grid")
                    .ToolBar(t =>
                    {
                        t.Search();
                    })
                    .Columns(columns =>
                    {
                        columns.Command(command => command.Custom("Zeige Details").Click("showDetails")).Width(100);
                        columns.Bound(p => p.Name).Filterable(filter => filter.Cell(cell => cell.Operator("contains").SuggestionOperator(FilterType.Contains)).Mode(GridFilterMode.Row));
                        columns.Bound(p => p.Abteilung).Filterable(filter => filter.Cell(cell=> cell.Operator("isequalto").SuggestionOperator(FilterType.Contains)));
                        columns.Bound(p => p.Kürzel).Filterable(filter => filter.Cell(cell => cell.Operator("contains").SuggestionOperator(FilterType.Contains)).Mode(GridFilterMode.Row));
                        columns.Bound(p => p.Durchwahl).Filterable(filter => filter.Cell(cell => cell.Operator("contains").SuggestionOperator(FilterType.Contains)).Mode(GridFilterMode.Row));
                        columns.Bound(p => p.Status).Filterable(filter => filter.Multi(true).CheckAll(false).BindTo(new[]
                        {
                            new { Status = "Abwesend"},
                            new { Status = "Anwesend"},
                            new { Status = "Pause"},
                            new { Status = "Dienstgang"},
                            new { Status = "Home Office"}
                        })).ClientTemplate("#=templateFunction(data)#");
                    })
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .ServerOperation(false)
                        .Read(read => read.Action("Phones_Read", "Home"))
                        .PageSize(50)
                        )
                    .Pageable(p => {
                        p.PageSizes(new[] { 20, 50, 100, 500 });
                    })
                    .Sortable()
                    .Filterable(filter => filter.Mode(GridFilterMode.Row))
                    )
                    
@(Html.Kendo().Window()
        .Name("Details")
        .Title("Mitarbeiterdetails")
        .Visible(false)
        .Modal(true)
        .Draggable(true)
        .Width(400)
    )
<script>
    function templateFunction(item) {

        if (item.Status == "Abwesend") {
            return "<span class='Abwesend'>" + item.Status + "</span>";
        }
        else if (item.Status == "Anwesend") {
            return "<span class='Anwesend'>" + item.Status + "</span>";
        }
        else if (item.Status == "Pause") {
            return "<span class='Pause'>" + item.Status + "</span>";
        }
        else if (item.Status == "Dienstgang") {
            return "<span class='Dienstgang'>" + item.Status + "</span>";
        }
        else {
            return "<span class='HomeOffice'>" + item.Status + "</span>";
        }

        return item.Status;
    }

    $(document).ready(function () {
        var refreshId = setInterval(function () {
            //GRID REFERENCE
            var grid = $("#grid").data("kendoGrid");            
            grid.dataSource.read();
        }, 60000);

    });

    
</script>

<script type="text/x-kendo-template" id="template">
    <div id="details-container">
        <h2>#= Name #</h2>
        <p><img src="https://profil.leonhardlang.at/#=MaId##=Organisation#.jpg?tag=@DateTime.Now" onerror="this.onerror=null; this.src='https://profil.leonhardlang.at/default.jpg?tag=@DateTime.Now'" alt="" width="auto" height="400" /></p>
        <em>Abeilung: #= Abteilung #</em><br>
        <em>Kürzel: #= Kürzel #</em>
        <dl>
            <dt>Durchwahl: #= Durchwahl #</dt><br>
            <dt>Status: #=templateFunction(data)# </dt>
        </dl>
    </div>
</script>

<script type="text/javascript">
    function showDetails(e) {
        e.preventDefault();

        var detailsTemplate = kendo.template($("#template").html());
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        var wnd = $("#Details").data("kendoWindow");

        wnd.content(detailsTemplate(dataItem));
        wnd.center().open();
    }
    $(function () {
        $(".k-input").focus();
    })
    
</script>

 

    
Cheers Drago
Petar
Telerik team
 answered on 11 Oct 2021
0 answers
66 views

I have the following code to create a Kendo Grid inside my custom HtmlHelper. The Ajax will return a 3 column data set to the DataSource (ID, Number, Name). No matter what I do, the Grid will return all the columns, and even if I try to change the title of the Number column to "Test Column" it has no effect. What am I missing? 


public static IHtmlContent FilterGrid<T>(this IHtmlHelper<T> html, string Name, string Controller) where T : class
        {
            HtmlContentBuilder htmlBuilder = new HtmlContentBuilder();

            htmlBuilder.AppendHtml(html.Kendo().DataSource<T>()
                .Name("ds_" + Name)
                .Ajax(dataSource => dataSource
                        .PageSize(20)
                        .Read(read => read.Action(Name + "_Read", Controller))
                    )
            );           

            htmlBuilder.AppendHtml(html.Kendo().Grid<T>()
                .Name("g_" + Name)
                .Pageable()
                .Sortable()
                .NoRecords()
                .DataSource("ds_" + Name)
                .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
                .Columns(c => {
                    c.Bound("Number").Title("Test title");
                    })
            ); 
            return htmlBuilder;
        }

Richard
Top achievements
Rank 1
 updated question on 08 Oct 2021
1 answer
110 views

Hello,

Is there are way to alter the font size or display for the ImageBrowser and FileBrowser in the Editor.

As you can see below, I have several similarly named folders and I'm not able to see the full folder name:

Is there something that can be done to alter the display sizes or layout?

Many thanks,

Richard

Petar
Telerik team
 answered on 08 Oct 2021
1 answer
116 views

I have detail grids for each row and when you make a change to the detail grid, it marks the parent grid as dirty. I then have a custom filter that looks for dirty rows and lets you toggle between showing modified rows or showing all rows. Works great except when I apply the filter, it tosses all the changes made to the detail grids. What can I do to keep those changes?

function toggleModifiedRows() {

    var grid = $("#grid").data("kendoGrid");
    var Filters = [];

    var buttonRows = document.getElementById('showModifiedRows');
    var buttonText = buttonRows.value;
    if (grid.dataSource.filter() != null) {
        Filters = grid.dataSource.filter().filters;
    }

    var FilterData = [];

    console.log(buttonText);
    if (buttonText == "Show Modified Rows") {
        buttonRows.value = "Show All Rows";
        var dirtyFilter = false;
        if (Filters.length > 0) {
            for (var i = 0; i < Filters.length; i++) {
                if (Filters[i].field == "dirty") { dirtyFilter = true; }
            }
        }
        if (!dirtyFilter) { FilterData = UpdateFilters(Filters, 'dirty', 'equals', true); }
    }
    else {
        buttonRows.value = "Show Modified Rows";

        if (Filters.length > 0) {
            for (var i = 0; i < Filters.length; i++) {
                if (Filters[i].field == "dirty") {
                    Filters.splice(i, 1);
                    break;
                }
            }
        }

        FilterData = Filters;
    }
    grid.dataSource.filter(FilterData);
};
Aleksandar
Telerik team
 answered on 07 Oct 2021
1 answer
1.0K+ views

Hello

We use ASP.NET Core Grid to display a list of objects, from the list, only one object can be selected (or any) and I know the selected object ID.

Is there a way to make a row selected by using that id? Also, a button should alow to change the selection.

Also, is there a way to add custom buttons with icons? say, "edit" button to link to the "id/edit" page(not popup), as well as delete and "view", for each row... 

 

I have the question on SO for several days: https://stackoverflow.com/questions/69404558/add-custom-button-to-the-telerik-grid

Stoyan
Telerik team
 answered on 06 Oct 2021
1 answer
993 views
I don't want to have to round trip for two items? How do I do that in TagHelpers?
Aleksandar
Telerik team
 updated answer on 06 Oct 2021
0 answers
145 views

I have copied over the demo: Chunk Upload in ASP.NET Core Upload Component Demo | Telerik UI for ASP.NET Core

Web project: netcoreapp3.1

We're using Telerik.UI.for.AspNet.Core Version="2020.2.617"

So far I have not been able to get the drop zone to show up, and I am also missing the hint text of "Drop files here to upload".

I tried adding it manually:

.Messages(
   builder =>
   {
      builder.DropFilesHere("Drop files here to upload");
   }
)

Clint
Top achievements
Rank 1
 asked on 05 Oct 2021
1 answer
124 views
How do I have the .Tools read in as a template stored externally to the page?  In short our code scanner does not like files over 100 lines, if you define .tools you easily get over 100 lines.  Code formatting breaks lines into items for readability, thus adversely impacting the scanner.
Aleksandar
Telerik team
 answered on 04 Oct 2021
1 answer
129 views

Hi,

 

We just upgraded kendo to the latest release and noticed that the Multiselect TagHelper for Asp.Net Core does not work as expected, it renders as a DropDownList not a MultiSelect.

 

Aleksandar
Telerik team
 answered on 01 Oct 2021
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?