Telerik Forums
UI for ASP.NET Core Forum
6 answers
532 views

Hi, 

 

I want to bind a label to a combobox using the tag '<label asp-for="test"></label>'.

I followed the online demo example exactly and it didn't work.

Is this a bug in the code for .NET CORE? 

Petar
Telerik team
 answered on 05 Dec 2019
1 answer
294 views

Hi,

I am using the scheduler but would like to pass the entered values in the scheduler (name, description, etc) to my C# controller, ideally within the kendo code in my view.

 

Could someone advise how to do this? I need to invoke a C# controller method on creation of an appointment.

Ivan Danchev
Telerik team
 answered on 03 Dec 2019
2 answers
285 views

 

I am a complete newbie to Kendo UI. I am trying to follow the getting started exercise https://docs.telerik.com/aspnet-mvc/helpers/data-management/grid/binding/custom-binding

Step 1

public ActionResult Index([DataSourceRequest(Prefix = "Grid")] DataSourceRequest request)

{

    IQueryable<Order> orders = new NorthwindEntities().Orders;

}

It does not recognise Prefix = "Grid".   The type of namespace 'Prefix' could not be found.

I cannot work out what namespace I need to resolve this.

Any help greatly appreciated.

I am using core 2.2 , VS 2017 and Kendo-UI 2019.3.1023

 

 

 

 

 

 

Aleksandar
Telerik team
 answered on 03 Dec 2019
14 answers
191 views

Hello

im trying to apply grouping

Here is my Read method

01.var result = await _helpDeskDbContext.Set<Ticket>()
02.               .Where(a => a.IsDeleted == false && AllowedCats.Contains(a.CategoryIdRef.Value))
03.               .OrderBy(a => a.Status.Sort)
04.               .Select(a => new TicketViewModel
05.           {
06.               Assignee = a.AssigneeUser.FullName,
07.               Category = a.Category.Name,
08.               Code = a.Code,
09.               Project = a.Project.Name,
10.               Id = a.Id,
11.               IsEditable = a.Status.IsEditable,
12.               Priority = a.Priority.Name,
13.               Requester = a.Requester.Name,
14.               RequestedOn = a.CreatedDate.ToString("yyyy/MM/dd hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
15.               Status = a.Status.Name,
16.               Subject = a.Subject,
17.               StatusCode = a.Status.Code,
18.               PriorityColor = new DataItem { text = a.Priority.ForeColor, value = a.Priority.BackColor },
19.               StatusColor = new DataItem { text = a.Status.ForeColor, value = a.Status.BackColor },
20.               ProjectColor = new DataItem { text = a.Project.ForeColor, value = a.Project.BackColor },
21.               StatusSort = a.Status.Sort
22.           }).ToDataSourceResultAsync(request);

 

and here is my grid configuration

.DataSource(op =>
                                       {
                                           op.Ajax().Model(m => m.Id(x => x.Id)).Group(a => a.Add(s => s.Assignee)).Read(r => r.Action("Read", "Tickets"));
                                       })

 

and the sql command from kestrel 

SELECT [t].[Assignee], [t].[Category], [t].[Code0], [t].[Project], [t].[Id], [t].[IsEditable], [t].[Priority], [t].[Requester], [t].[CreatedDate], [t].[c], [t].[Status], [t].[Subject], [t].[StatusCode], [t].[text], [t].[value], [t].[text0], [t].[value0], [t].[text1], [t].[value1], [t].[StatusSort], [t].[FullName], [t].[Name], [t].[Code], [t].[Name], [t].[IsEditable], [t].[Name], [t].[Name], [t].[Name], [t].[Code], [t].[ForeColor], [t].[BackColor], [t].[ForeColor], [t].[BackColor], [t].[ForeColor], [t].[BackColor], [t].[Sort]
      FROM (
          SELECT [a.AssigneeUser].[FullName] AS [Assignee], [a.Category].[Name] AS [Category], [a].[Code] AS [Code0], [a.Project].[Name] AS [Project], [a].[Id], [a.Status].[IsEditable], [a.Priority].[Name] AS [Priority], [a.Requester].[Name] AS [Requester], [a].[CreatedDate], N'yyyy/MM/dd hh:mm tt' AS [c], [a.Status].[Name] AS [Status], [a].[Subject], [a.Status].[Code] AS [StatusCode], [a.Priority].[ForeColor] AS [text], [a.Priority].[BackColor] AS [value], [a.Status].[ForeColor] AS [text0], [a.Status].[BackColor] AS [value0], [a.Project].[ForeColor] AS [text1], [a.Project].[BackColor] AS [value1], [a.Status].[Sort] AS [StatusSort]
          FROM [HelpDesk].[Tickets] AS [a]
          LEFT JOIN [HelpDesk].[Contacts] AS [a.Requester] ON [a].[RequesterIdRef] = [a.Requester].[Id]
          LEFT JOIN [HelpDesk].[Priorities] AS [a.Priority] ON [a].[PriorityIdRef] = [a.Priority].[Id]
          LEFT JOIN [HelpDesk].[Projects] AS [a.Project] ON [a].[ProjectIdRef] = [a.Project].[Id]
          LEFT JOIN [HelpDesk].[Categories] AS [a.Category] ON [a].[CategoryIdRef] = [a.Category].[Id]
          LEFT JOIN [HelpDesk].[Status] AS [a.Status] ON [a].[StatusIdRef] = [a.Status].[Id]
          LEFT JOIN [dbo].[UserInfos] AS [a.AssigneeUser] ON [a].[AssigneeIdRef] = [a.AssigneeUser].[UserId]
          WHERE ([a].[IsDeleted] = 0) AND COALESCE([a].[CategoryIdRef], 0) IN (3)
          ORDER BY [a.AssigneeUser].[FullName], [a.Status].[Sort]
          OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY
      ) AS [t]
      ORDER BY [t].[FullName]

 

in the read method gives error 500 and the i looked to my error logs and i found below error 

 

System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'FullName'.
Invalid column name 'Name'.
Invalid column name 'Code'.
Invalid column name 'Name'.
Invalid column name 'Name'.
Invalid column name 'Name'.
Invalid column name 'Name'.
Invalid column name 'Code'.
Invalid column name 'ForeColor'.
Invalid column name 'BackColor'.
Invalid column name 'ForeColor'.
Invalid column name 'BackColor'.
Invalid column name 'ForeColor'.
Invalid column name 'BackColor'.
Invalid column name 'Sort'.
Invalid column name 'FullName'.

 

please i need help.

am i doing something wrong ? or its in Telerik side

Thanx

Ahmed

NoobMaster
Top achievements
Rank 2
Iron
 answered on 03 Dec 2019
1 answer
111 views

my code as blow:

function GridDataSource(gridName,path, readHandler, createHandler, updateHandler,deleteHandler, model) {

            var grid = GetGrid(gridName);
            var urlRead = '@Url.Content("~")' + encodeURI(path + "?handler=" + readHandler );
            var urlCreate = '@Url.Content("~")' + encodeURI(path + "?handler=" + createHandler);
            var urlUpdate = '@Url.Content("~")' + encodeURI(path + "?handler=" + updateHandler);
            var urlDestroy = '@Url.Content("~")' + encodeURI(path + "?handler=" + deleteHandler);


            if (model == null)
                model = { id: "Id" };

            var dataSource = new kendo.data.DataSource({
                type: "aspnetmvc-ajax",
                pageSize: 1000,
                serverPaging: false,
                serverGrouping: false,
                transport: {
                    read: {
                        url: urlRead,
                        data: kendo.antiForgeryTokens(),
                    },
                    create: {
                        url: urlCreate,
                        data: kendo.antiForgeryTokens(),
                        cache: true
                    },
                    update: {
                        url: urlUpdate,
                        data: kendo.antiForgeryTokens(),
                    },
                    destroy: {
                        url: urlDestroy,
                        data: kendo.antiForgeryTokens(),
                        cache: true
                    },
                    parameterMap: function (data, type) {
                        if (type == "create") {
                            // send the created data items as the "models" service parameter encoded in JSON
                            return { models: kendo.stringify(data.models) };
                        }
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors",
                    model: model
                }
            });


            grid.bind("dataBound", function () {

                if (grid.dataSource.data().length>0)
                    grid.select("tr:eq(0)");

            });
            grid.setOptions({
                dataSource: dataSource,
                persistSelection: true,
            });

            //grid.setDataSource(dataSource);

        }

 

function BtnAddClientClick(e) {
        var ds = GetGrid("DgClient").dataSource;
        var newRow = kendo.observable({
            Id: Guid(),
            Clientname: "xxxxx",
            Status: "Draft",
            Comments: ""
        });

        var dataItem = ds.insert(0, newRow);
        ds.sync();
    }

 

public ActionResult OnPostAddClient([DataSourceRequest]DataSourceRequest request, Cmclient client)
        {
            var data = Request.Form;
            var id = data["Id"][0];

            return new JsonResult("OK");

            //ds.Cmclient.Add(client);
            //ds.SaveChanges();
            //return new JsonResult(new[] { client }.ToDataSourceResult(request, ModelState));
        }

 

 

not work. why? please help.

Alex Hajigeorgieva
Telerik team
 answered on 03 Dec 2019
1 answer
4.7K+ views

How can I set the background color of a DropDownList's selected value box. Adding the following to the DropDownList html helper code: .ValueTemplate("<div style='background-color:yellow'>#= data.Role #</div> results in just the background of the value text being colored yellow. The background of the entire box not behind the value text remains unchanged.

 

Martin
Telerik team
 answered on 02 Dec 2019
3 answers
884 views

Hello,

can you please provide a Sample for using Partial Razor Pages for Grid Create/Edit actions. I want to use my custom Pages within Modal Popups. Haven't found anything in this direction in the documentation or samples here. 

Really appreciate your help

 

Best regards

Paul

Tsvetomir
Telerik team
 answered on 02 Dec 2019
1 answer
397 views

Your online examples need explanation.  Just putting the code out there is not considered best practice.  This example:

https://demos.telerik.com/aspnet-mvc/combobox/cascadingcombobox

I'm trying to get the cascading going using ASP.NET Core MVC.  I am able to get the first combo box working.  But, the cascade action doesn't work.  Your example references objects that have no definition so I'm lost.  For example:

productFilter: $("#products").data("kendoComboBox").input.val()

What is the "kendoComboBox" referring to?  What is it and where did it originate?

 

Here is my attempt:

<div class="form-group">
    <label asp-for="DefaultCountryCode" class="control-label"></label><br />
    @(Html.Kendo().ComboBoxFor(x => x.DefaultCountryCode)
          .Placeholder("Select Country...")
          .DataTextField("Name")
          .DataValueField("Context")
          .Filter(FilterType.Contains)
          .DataSource(source =>
          {
              source.Read(read =>
              {
                  read.Action("GetCountries", "Persons");
              });
          })
          .HtmlAttributes(new { style = "width: 100%" }))
</div>
<div class="form-group">
    <label asp-for="DefaultTimeZoneId" class="control-label"></label><br />
    @(Html.Kendo().ComboBoxFor(x => x.DefaultTimeZoneId)
          .Placeholder("Select Time Zone...")
          .DataTextField("Comment")
          .DataValueField("ZoneId")
          .Filter(FilterType.Contains)
          .DataSource(source =>
          {
              source.Read(read =>
              {
                  read.Action(
                      "GetTimeZoneByCountryCodeAsync",
                      "Persons")
                      .Data("filterZones");
              });
          })
          .HtmlAttributes(new { style = "width: 100%" })
          .Enable(false)
          .AutoBind(false)
          .CascadeFromField("DefaultCountryCode")
          )
    <script>
        function filterZones() {
            return {
                countries: $("#countries").val(),
                productFilter: $("#timeZones").data("kendoComboBox").input.val()
            };
        }
    </script>
</div>

 

The "DefaultCountryCode" combobox is working.

Your example seems to refer to the other combobox using the value in the "combobox.name" property.  However, I tie this to the model using ComboBoxFor. 

2nd ComboBox:

  • I need the ComboBox1.DataValueField("Context") value to be used to submit the value to ComboBox2
  • How do I tie the 2nd to the 1st combobox in this scenario?  I'm guessing by using the "combobox.CascadeFromField" approach.  
  • The example sets the Enable property to false and AutoBind to false.  Why?  Give me documentation.
  • The example references the filterProducts (filterZones) script to feed the read.Action.Data combobox.Datasource.  When doing "combobox.CascadeFromField", is this necessary?  My script isn't working and the Action is never fired.

Thanks for your help,

Joel

Aleksandar
Telerik team
 answered on 29 Nov 2019
1 answer
648 views

Working with the Core grid I noticed that the excel export autowidth is not working for date columns.  Every other column is working but not dates.  Here is my function for the export...

function gridReport_ExcelExport(e) {
    var sheet = e.workbook.sheets[0];
    for (var rowIndex = 0; rowIndex < sheet.rows.length; rowIndex++) {
        var row = sheet.rows[rowIndex];
        var expandRow = false;
        for (var cellIndex = 0; cellIndex < row.cells.length; cellIndex++) {
            var cell = row.cells[cellIndex];
            if (rowIndex > 0)
                cell.vAlign = "top";
            if (cell.value && cell.value.toString().indexOf("<br />") >= 0) {
                cell.value = cell.value.replace("<br />", "\n");
                cell.wrap = true;   
                expandRow = true;
            }
        }
        if (rowIndex > 0)
            sheet.rows[rowIndex].height = 50;
    }   
    for (var colIndex = 0; colIndex < sheet.columns.length; colIndex++) {
        var column = sheet.columns[colIndex];
        delete column.width;
        column.autoWidth = true;
    }
}

 

I found a kendo dojo and was able to duplicate the issue there also.  (http://dojo.telerik.com/oGafisuF)  I modified it as this...

<body>
  <div id="grid"></div>
  <script>
    var dt = new Date();
  $("#grid").kendoGrid({
    dataSource: [
      { foo: "foo", bar: "bar", somedate: dt }
    ],
    toolbar:["excel"],
    columns: [
      { field: "foo", width: "100px"},
      { field: "bar", width: "200px"},
      { field: "somedate", width: "100px", template: "#= kendo.toString(kendo.parseDate(somedate, 'yyyy-MM-dd'), 'MM/dd/yyyy') #"}
    ],
    excelExport: function(e) {
      var sheet = e.workbook.sheets[0];
      for (var i = 0; i < sheet.columns.length; i++) {
        delete sheet.columns[i].width;
        sheet.columns[i].autoWidth = true;
      }
    }
  });
  </script>
</body>

 

Angel Petrov
Telerik team
 answered on 29 Nov 2019
6 answers
227 views
I would like to utilise the SignalR data binding patterns while using the grid tag helpers however I can find no supporting documentation and no obvious way of configuring. Is SignalR binding supported with the tag helpers, if so is there any documentation to assist me? If not is this in the development roadmap and what are my current workaround options?

Thanks for any help you can offer.

Danny
Keisuke
Top achievements
Rank 1
 answered on 28 Nov 2019
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?