Telerik Forums
UI for ASP.NET Core Forum
1 answer
115 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
901 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
402 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
654 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
236 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
2 answers
137 views

I have converted our solution in the last couple of days from .NET Core 2.2 to 3.0.

The last component to integrate is Kendo.Core UI MVC.  The ASP.NET site compiles and runs, including the WebAPI project but the grids are not rendering data.  And we have a lot of grids in a lot of templates.  None work.  In the debugger you can see that the following statement in the *_Read methods have data, the dsResult.Data has data ans no errors but the data does not show.

var dsResult = result.ToDataSourceResult(request);
            return Json(dsResult);

This is using 2019.3.0123.

I also opened up a working POC prototype basic Kendo application that worked fine in 2.2, showing data.  This was created about 6 months ago using the wizard in VS 2017.  I am now using VS 2019. 

The project  dynamically creates the data for the read method, simple as could be.  But after upgrading the project to.NET Core 3.0 the data fails to show.  Again the debugger shows the result to the request formed fine.  So I suspect the issue is in the binding to the grid.


Can someone at Progress shed some light on this?

If you look at the link below it is states, 

"With the Telerik R3 2019 release, you will be better equipped to continue doing just that. We are so proud to release the all-new Telerik UI for Blazor, which is packed with more than 25 brand-new native components!"
In addition, we are happy to announce that our component .NET toolsets are fully compliant with the upcoming .NET Core 3.0 and are coming with tons of new controls and improvements.  

https://www.telerik.com/blogs/telerik-and-kendo-ui-r3-release-2019-is-here!

Thanks

 

Reid
Top achievements
Rank 2
 answered on 28 Nov 2019
2 answers
1.3K+ views

How do I display the Local DateTime in your control?  Razor renders everything on the Server but I need to display DateTime values in the context of the Browser's TimeZone.  Couple of scenarios:

  • I want to pull the DateTime value from the browser using JavaScript and display it in your Browser. 
  • I have a UTC DateTime value stored in the database but when displaying that value I need it to display in the TimeZone of the browser.
  • I have a DateTime with the Offset stored in the database.  How do I display that value in the TimeZone of the broswer.

Is there some type of event that I can tie in to that could be used to call an Action on my Controller similar to your other (Grid, Hierarchy) controls that would supply the TimeZone information?

Joel
Top achievements
Rank 2
Bronze
Iron
Iron
 answered on 26 Nov 2019
2 answers
144 views

Hello I have existing data grid in an ASP.NET Core project. I want to attach the new Kendo Filter to that grid without specifying the data source name explicitly.

Is there any way to do this?

Nikolay
Top achievements
Rank 1
Iron
 answered on 26 Nov 2019
5 answers
191 views

How can I get all the visible events in the current view?

I can't use the date range to do this since I'm using a filter to filter the events by resource. For instance, if I have events A, B, C using resource 1, E, F using resource 2, after I filter the scheduler by resource 2, only events E and F will be visible. How can I get those 2 visible events in the client side?

Aleksandar
Telerik team
 answered on 25 Nov 2019
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?