Telerik Forums
UI for ASP.NET Core Forum
1 answer
231 views

I have a bool column

public bool isValid {set;get}

I have defined a custom template and filter.

 columns.Bound(c => c.isValid).Filterable(f => f
            .Cell(c => c.Template("MyBooleanCellTemplate"))
            ).ClientTemplateId("isValid").Title("Valid").Width(75);

<script>
    function MyBooleanCellTemplate(args) {
        var radioInput = $("<input type='radio'/>"); // Get the radio input element.
        var wrapper = args.element.parent(); // Obtain the parent container of the radio buttons.
        var inputName = kendo.guid(); // Specfify an unique element.

        args.element.remove(); // Remove the element.

        var labelTrue = $("<label/>")
            .text("")
            .append("<i style='color:green; font-size: 20px;' class='k-icon k-i-check'></i>")
            .append(radioInput); // Create a label that will contain the icon and add it to the radio input.

        radioInput.attr(kendo.attr("bind"), "checked:value") // Add the "bind" attribute, specify the unique and, and set a value.
            .attr("name", inputName)
            .val("true");

        var labelFalse = labelTrue.clone() // Create a label for the second radioInput that will contain an icon.
            .text("")
            .append("<i style='color:red; font-size: 20px;' class='k-icon k-i-x'></i>");

        radioInput.clone() // Clone the previously obtained radio button, set its value and append to the previously created label.
            .val("false")
            .appendTo(labelFalse);


        wrapper.append([labelTrue, labelFalse]); // Append both of the created labels.
    };
</script>

 

Also I have set default true on pageload.

 

I only want to see true or false value not both,

How remove the filter clear icon.

Aleksandar
Telerik team
 answered on 28 Nov 2022
1 answer
110 views

I am using the telerik report designer to build my reports and html report viewer to display them.
When I use MySql.Data.MyqlClient with a standard connection string (server, uid etc) everything works fine.

When I use a ODBC dsn connection however, the connection works on the report builder but on the report viewer it says the following:

An error has occurred while processing Table 'table2':Unable to establish a connection to the database. Please verify that your connection string is valid. In case you use a named connection string from the application configuration file, make sure the name is correct and the connection string settings are present in the configuration file of your application.------------- InnerException -------------Keyword not supported: 'dsn'

I do have System.Data.Odbc installed as this is what I used for my db connections and this is also what the report builder uses.

Telerik Reporting v16.2

.Net core 6 (long term support)

Dinesh
Top achievements
Rank 1
Iron
 answered on 25 Nov 2022
9 answers
954 views

Hi,

I'm having an issue getting a foreign key column to persist in the grid. Here's my grid...

@(Html.Kendo().Grid<GridDataItem>(Model.GridDataItems)
    .Name("gridDataItems")
    .Columns(columns =>
    {
      columns.Bound(model => model.Name);
      columns.ForeignKey(model => model.ChildDataItemId, Model.AllChildDataItems, "Id", "Value");//.EditorTemplateName("_ForeignKeyDropDown");
      columns.Command(command =>
      {
        command.Edit();
      }).Width(172);
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.PopUp))
    .DataSource(dataSource => dataSource
      .Ajax()
      .PageSize(20)
      .ServerOperation(false)
      .Model(model =>
      {
        model.Id(p => p.Id);
      })
    )
  )

Here's the controller...

public class GridTestController : Controller
    {
        public IActionResult Index()
        {
            var viewModel = new GridTestModel
            {
                GridDataItems = new List<GridDataItem>
                {
                    new GridDataItem
                    {
                        Id = 1,
                        Name = "Record 1",
                        ChildDataItemId = 2
                    },
                    new GridDataItem
                    {
                        Id = 2,
                        Name = "Record 2",
                        ChildDataItemId = 3
                    },
                    new GridDataItem
                    {
                        Id = 3,
                        Name = "Record 3"
                    }
                }
            };
 
            return View(viewModel);
        }
    }

and here's the Model...

public class GridTestModel
    {
        public List<GridDataItem> GridDataItems { get; set; }
 
        public List<ChildDataItem> AllChildDataItems
        {
            get
            {
                return new List<ChildDataItem>
                {
                    new ChildDataItem
                    {
                        Id = 1,
                        Value = "Option 1"
                    },
                    new ChildDataItem
                    {
                        Id = 2,
                        Value = "Option 2"
                    },
                    new ChildDataItem
                    {
                        Id = 3,
                        Value = "Option 3"
                    }
                };
            }
        }
    }
 
    public class GridDataItem
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int? ChildDataItemId { get; set; }
        public ChildDataItem ChildDataItem { get; set; }
    }
 
    public class ChildDataItem
    {
        public int Id { get; set; }
        public string Value { get; set; }
    }

The values for Option 1 and Option 2 can be updated fine (as they're preset with a non-null value) but I'm not able to select a value for the Option 3 record nor am I able to set the foreign key value (ChildDataItemId) for a new record.

Anyone an idea as to why? I've also tried a custom editor template for the drop down field using .ValuePrimitive(true) but this has no effect.

Thanks
Stuart.

huangjia
Top achievements
Rank 1
Iron
 answered on 23 Nov 2022
1 answer
925 views

We're using Kendo Grids for our .NET Core application. We display checkbox lists in the column headers so the user can filter in the Kendo Grid. The problem is that the items in these checkbox list are not sorted (even if we pass sorted items to it).

We tried to add a fix by adding the following FilterMenuInit client side event to try to sort the checkbox list column header items

function onFilterMenuInit(e) {
        var filterMultiCheck = this.thead.find("[data-field='" + e.field + "']").data("kendoFilterMultiCheck");

        if (filterMultiCheck) { 
            filterMultiCheck.container.empty();
            filterMultiCheck.checkSource.sort({ field: e.field, dir: "asc" });
            filterMultiCheck.checkSource.data(filterMultiCheck.checkSource.view().toJSON());
            filterMultiCheck.createCheckBoxes();
        }
}


The fix is causing the following issue:

VM4956:3 Uncaught TypeError: Cannot read properties of null (reading 'Id')
    at eval (eval at filter (kendo.min.js:9:168981), <anonymous>:3:25)
    at r.filter (kendo.min.js:9:169113)
    at r.process (kendo.min.js:9:171128)
    at init._queryProcess (kendo.min.js:9:190070)
    at init.query (kendo.min.js:9:191247)
    at init._query (kendo.min.js:9:191778)
    at init.filter (kendo.min.js:9:192662)
    at init._filter (kendo.min.js:9:918467)
    at HTMLFormElement.r (website.min.js:14:21692)
    at HTMLFormElement.dispatch (website.min.js:14:57771)

 

This is happening on the Kendo side. Is this a bug? Is there an alternative way to sort these checkbox list in the column headers?

Alexander
Telerik team
 answered on 23 Nov 2022
0 answers
110 views

Scenario and Issue:

I had a Tabstrip with three tabs,

in each tab there are four DropDownList and four line charts.

However, If I bind all the data once (Include DropDownLists and Line Charts in three tabs),

the page would rendered slowly and caused some of the data loss binding.

Question1 :

I'm wondering if it's possible to render Line Chart before data binding?

then I'll data bind it after DropDownList Select event was triggered.

Or is there any other alternative ways?

What I've Tried

The TabStrip is in a partialview,

once a button was clicked the partialview will be load with javascript function by.
 $("#myHtmlElementId").load('@Url.Action("MyAction","MyController")', params)

The complicated part is the line chart in initial tab strip was data binded with local binding the data passed by ViewBag.

And if I try to render the other line chart while the second or third TabStrip Item was selected.

It's logic would be conflict, if the user clicked the first TabStrip again.

Since the line chart were data binded with local data by ViewBag,

and the others in 2nd or 3rd TabStrip were renderd while the TabStrip item was selected,

And the selected event would call a javascript function to render another partial view to fill content into the TabStrip.

Is there something like TabStrip initial event? 

So that I could also fill the first Tabstrip item contents same as the 2nd or 3rd TabStrip.

CHIHPEI
Top achievements
Rank 2
Iron
Iron
Iron
 asked on 22 Nov 2022
1 answer
96 views

Hi,

I want to use the Upload function to read data in excel spreadsheet. The requirement is to show a pop up to prompt the user to delete any existing data before uploading any new data. 

How to show this pop up. Could you please help?

 

Regards,

Monika

 

Aleksandar
Telerik team
 answered on 18 Nov 2022
1 answer
1.4K+ views

I have a checkbox that is checked on a form but it should send its value on the post but should not be editable

The editor template looks like this

@(Html.Kendo().CheckBoxFor(m => m)
         .Label(label)
         .Enable(enable)
         .HtmlAttributes(ViewData)
         .Deferred(deferred)
   )

The checkbox does not have a readonly functionality like the textbox

Can this be achieved? I tried adding a hidden field like @Html.HiddenFor(m => m) but that generates another input with the same id

Mihaela
Telerik team
 answered on 15 Nov 2022
1 answer
335 views

I am using a Grid , 

Suppose there are two columns and two Edit buttons ,while clicking the first edit button only edit the first column and second edit button for second column. Save button needs to called to different endpoints with the data.

Mihaela
Telerik team
 answered on 11 Nov 2022
1 answer
333 views

Good morning everyone

Apologies, i hope i'm posting in the correct subforum.

A bit of background: we are using a web application creating with telerik controls. the SQL server that the application was connecting to died and we had to rebuild it using a new version of SQL. This changed causes the error - "Failed to retrieve the automatically incremented column value from the server. Possible reason: A trigger does not perform 'select ID from inserted'" when we try to create new items through the web app

i came accross this old post https://www.telerik.com/forums/telerik-bug-in-sql-server-2014-sp1 which shows that a number of hotfixes were made available at the time

We are using this version of telerik - Telerik.OpenAccess.Runtime, Version=2013.1.219.3, now with this version of SQL Microsoft SQL Server 2016 (SP3-GDR) (KB5014355) - 13.0.6419.1 (X64) 

I tried the 2013 hotfix version from the post which is a slightly different  from what we have.  ( i tired the newer ones to but unsurprisignly the broke the site.)The hot fix allowed the web app to load, but it couldnt load the  content of the web form.

I was wondering if you could please provide an hot fix for that version, if at all possible.

Thank you for your time

Viktor Zhivkov
Telerik team
 answered on 08 Nov 2022
1 answer
567 views

Scenario:

I would like to retrieve data with ajax,

once getting data from my database,

then pass Json data back to frontend and refresh line chart

Question:

While I got the data and pass it back to frontend,

it showed type error: Cannot read property 'getTime' of undefined.

What could cause this error?

To be mentioned, the json Data is in the same type with line chart, which is IEnumerable<EqEvDTDataViewModel>.

Code:

My Ajax Function

function instDataChartDropDownSelect(e) {

            var dataItem = this.dataItem(e.item);
            var instID = dataItem.InstID;

            $.ajax({
                type: "POST",
                url: '@Url.Action("MyAction","MyController")',
                data: { 'instID': instID },
                dataType: 'json',
                success: function (response) {
                    $("#dtchart").data("kendoChart").dataSource.data(response);
                },
                error: function (response) {
                }
            });
        }

My Line Chart
@(Html.Kendo().Chart(instDatas.EqEvDTDataViewModel)
                                        .Name("dtchart")
                                        .Title("DT Time History Chart")
                                        .Legend(legend => legend
                                            .Position(ChartLegendPosition.Bottom)
                                        )
                                        .ChartArea(chartArea => chartArea
                                            .Background("transparent")
                                        )
                                        .SeriesDefaults(seriesDefaults =>
                                            seriesDefaults.Line().Style(ChartSeriesStyle.Smooth)
                                        )
                                        .Series(series => {
                                            series.Line(model => model.ReadData).Name("Displacement");
                                        })
                                        .ValueAxis(axis => axis
                                            .Numeric()
                                        )
                                        .CategoryAxis(axis => axis
                                            .Categories( m => m.ReadTime)
                                            .Type(ChartCategoryAxisType.Date)
                                            .BaseUnit(ChartAxisBaseUnit.Fit)
                                            .Labels(labels => labels.Rotation(-90))
                                            .Crosshair(c => c.Visible(true))
                                            .AutoBaseUnitSteps(config => config.Milliseconds(1))
                                        )
                                        .Tooltip(tooltip => tooltip
                                            .Visible(true)
                                            .Shared(true)
                                            .Format("{0:N0}")
                                        )
                                 )

CHIHPEI
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 07 Nov 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?