Telerik Forums
UI for ASP.NET Core Forum
3 answers
220 views
Created an application with Telerik Kendo UI or Asp.Net Core 2.0 controls. We used some controls which work perfectly in development. Locally we are able to run the same code without error in Visual Studio 2017, but after publishing in local IIS it gives below error( see attached image).

Error : - "http://localhost:91/Master/StateMaster/GetStateList 404 (Not Found)". 

While checking the error found that there only Read method (may be due to '[DataSourceRequest]DataSourceRequest' parameter) of a grid cannot call (  action method is perfectly called like in below code 'GetRecordStatusList()')


Our controller 
    [Area("Master")]
public class StateMasterController : Controller
    {
private IAllRepository<StateMaster> iAllStateRepository;

public IActionResult StateMaster()
{
List<SelectListItem> statusList = new List<SelectListItem>() {
new SelectListItem{Text = "Active", Value = "1" },
new SelectListItem{Text = "Inactive", Value = "2" }
};
ViewData["Status"] = statusList;

HttpContext.Session.SetInt32("UserId", 1);
HttpContext.Session.SetString("UserName", "Admin");
ViewBag.UserName = HttpContext.Session.GetString("UserName");

return View();
}

//This action method is not called in published-code
public ActionResult GetStateList([DataSourceRequest]DataSourceRequest request)
{
this.iAllStateRepository = new StateMasterRepository();
var result = iAllStateRepository.GetModelList();
var dsResult = result.ToDataSourceResult(request);
return Json(dsResult);
}

public JsonResult GetRecordStatusList()
{
List<SelectListItem> statusList = new List<SelectListItem>() {
new SelectListItem{Text = "Active", Value = "1" },
new SelectListItem{Text = "Inactive", Value = "2" }
};
return Json(statusList);
}
}


Georgi
Telerik team
 answered on 06 Aug 2018
1 answer
639 views

Hi, I'm looking for help disabling an entire rows edit abilities by using the value in one of the columns.

ex.

...

            columns.Bound(p => p.releaseState).Title("Release State");
            columns.Command(command => {command.Edit().Visible("isEditable(releaseState)");});

...

 

This does not work neither does isEditable(p.releaseState) or isEditable(Model.releaseState)...

Any help would be greatly appreciated.

Eyup
Telerik team
 answered on 05 Aug 2018
1 answer
362 views

I was trying to get DatePickerFor work on a Kendo Grid Popup editor with no luck. I've already spent countless hours first with the DropDownListFor (https://www.telerik.com/forums/dropdownlistfor-events-in-razor-pages) which still doesn't work and now with DatePickerFor. Any help is much appreciated.

I have the DatePickerFor in a Kendo Grid Popup Template.

Grid:

.DataSource(dataSource => dataSource
                .Custom()
                .Transport(t => {
                    t.Read(r => r.Action("Cases", "CaseList", new { handler = "GetCases" }).Type(HttpVerbs.Post).Data("sendAntiForgeryToken"));
                    t.Create(r => r.Action("Cases", "CaseList", new { handler = "AddCase" }).Type(HttpVerbs.Post).Data("sendAntiForgeryToken"));
                })

Razor Page:

public JsonResult OnPostAddCase([DataSourceRequest] DataSourceRequest request, CaseModel newCase)
        {
            if(ModelState.IsValid)
            {
               
            }
        }

 

Popup Template:

@(Html.Kendo().DatePickerFor(model => model.LetterDate)
                        .HtmlAttributes(new { style = "width:150px; font-size:14px" })
            )

Model:

[DataType(DataType.Date, ErrorMessage ="Letter Date is required")]
        [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
        [Display(Name ="LetterDate")]
        public DateTime LetterDate { get; set; }

FormData:

LetterDate: Tue Jul 31 2018 13:04:15 GMT-0400 (Eastern Daylight Time)

Error: The value 'Tue Jul 31 2018 13:04:15 GMT-0400 (Eastern Daylight Time)' is not valid for LetterDate.

I have tried several solutions like setting up the culture, changing the formats but nothing seems to work.

The only option that I'm left with is intercepting the date before submit. But before I do that I would like to know why it is so hard to get the basic functionality work with kendo controls. This is so frustrating.

Georgi
Telerik team
 answered on 03 Aug 2018
8 answers
257 views

I have an application that uses the SCSS telerik theme

/*Bootstrap v4 custom variables*/
@import "lib_overwrite/bootstrap_variables_overwirte";
 
/*Kendo UI custom variables*/
@import "lib_overwrite/sbkvariables";
 
/*Keno UI - Bootstrap v4 theme*/
@import "../../../node_modules/@progress/kendo-theme-bootstrap/scss/all";
 
/*Original Bootstrap v4 reboot*/
@import "../../../node_modules/bootstrap/scss/bootstrap-reboot";
 
/*Original Bootstrap v4*/
@import "../../../node_modules/bootstrap/scss/bootstrap";
 
/*Custom sass*/
@import "main";

but the resulting css does not contain the browser prefix styles. I have found this because on IE 11 the filter grid row contains the input fields but they do not have the same width as the column. But If I add the "-ms-flex 1 1 0px" that exist on the telerik site the input fields have the correct width.

How can the browser prefix be generated using SCSS for the telerik?

Plamen
Telerik team
 answered on 03 Aug 2018
5 answers
2.3K+ views

I'm trying to add Change Event for DropDownListFor in Razor Pages but facing an issue - "Cannot use lambda expression..."

@(Html.Kendo().DropDownListFor(model => model.CaseSourceCode)

                         .BindTo(ViewBag.LookupSourceTypes)

                         .Events(e => e.Change("OnChange")

)

 

If I don't add the Events line the DropDownListFor works just fine.

 

AJ
Top achievements
Rank 1
 answered on 02 Aug 2018
6 answers
1.6K+ views

I have a Kendo Grid and would like to bind to the server-side WebAPI call result after the postback. The Grid result is based upon the selected dropdown value when the submit button is clicked. I am able to invoke the button click event, bind the webapi result to the Input.PermitList JSON result  attribute. But the Grid is still empty. Anything I might have missed? Please suggest

Front-end code

 <form method="post">
    <h2>Permits</h2>
    <div>
        <label asp-for="Input.PermitCategoryList" class="control-label"></label>
        <kendo-dropdownlist name="categories" for="@Model.Input.PermitCategory"
                            option-label="Select permit Category..."
                            class="form-control"
                            bind-to="@(new SelectList(@Model.Input.PermitCategoryList,"Alias","Name"))"></kendo-dropdownlist>
        <span asp-validation-for="Input.PermitCategoryList" class="text-danger"></span>
    </div>
    <div>
        <button name="btnGetPermit" icon="filter" type="submit" asp-page-handler="PermitList" class="k-button">Get Permits</button>
    </div>

    <div>
        <h4>Permits</h4>
        <kendo-grid name="grid" height="550" datasource-id="dataSource">
            <groupable enabled="true" />
            <sortable enabled="true" />
            <pageable button-count="5" refresh="true" page-sizes="new int[] { 5, 10, 20 }">
            </pageable>
            <filterable enabled="true" />
            <columns>
                <column field="Id" title="Permit Id" />
                <column field="Class" title="Permit Class" />
                <column field="Name" title="Permit Name" />
                <column field="Type" title="Permit Type" />
                <column field="Fee" title="Permit Fee" />
            </columns>
        </kendo-grid>
    </div>

    <script>
    var data = @LITSPermitting.Admin.Extensions.JavaScriptConverter.SerializeObject(Model.Input.PermitList);

    var dataSource = new kendo.data.DataSource({
        data: data,
        pageSize:5
    })
    </script>
</form>

Back-end Button click event

        [BindProperty]
        public InputModel Input { get; set; }

        public class InputModel
        {
            [Required]
            [Display(Name = "Permit Category")]
            public List<PermitCategoryDto> PermitCategoryList { get; set; }

            public string PermitCategory { get; set; }

            public JsonResult PermitList { get; set; }
        }

 

        /// <summary>
        /// Get a list of Permits based upon the category request
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task<ActionResult> OnPostPermitListAsync([DataSourceRequest]DataSourceRequest request)
        {
            await HttpContext.Session.LoadAsync();
            Input.PermitCategoryList = HttpContext.Session.Get<List<PermitCategoryDto>>(Constants.PERMIT_CATEGORY_LIST);

            //tp is the temporary permit type
            string requestUri = Constants.PERMIT_CATEGORY_REQUEST_URI + Input.PermitCategory;

            _response = await _client.GetAsync(requestUri);
            if (_response.IsSuccessStatusCode)
            {
                //Storing the response details recieved from web api     
                var result = _response.Content.ReadAsStringAsync().Result;

                //Deserializing the response recieved from web api and storing into the Permit list    
                var drResult = JsonConvert.DeserializeObject<List<PermitDto>>(result);

                Input.PermitList=new JsonResult(drResult.ToDataSourceResult(request)); 
                return Input.PermitList;
            }
            else
            {
                return NotFound();
            }

        }

 

 

Jonathan
Top achievements
Rank 1
 answered on 02 Aug 2018
1 answer
164 views

Is there an documentation on how to do some custom validation? Or even better, know how to handle an exception being returned? Such as, "A file with that name already exists"?

Right now if I just throw an error in my action method, it just shows that is was unsuccessful but I cannot give it a reason for why it failed on the async save.

Peter Milchev
Telerik team
 answered on 01 Aug 2018
1 answer
484 views

Hi,

Is it possible to use tag helpers with model validation using Kendo's validation framework?

C#

[Required]
public string Title { get; set; }

 

HTML

<kendo-maskedtextbox for="Title"></kendo-maskedtextbox>
<span data-for="Title" class="k-invalid-msg"></span>

 

JS

var validator = $("#changeForm").data("kendoValidator");

validator.validate();

 

I can't seem to get the required validation to appear.  The form posts even if the control is blank.  Can anyone give me a working example of model validation with tag helpers in .NET Core?

Thanks!

Dimitar
Telerik team
 answered on 31 Jul 2018
1 answer
220 views

Hello everybody!

I would like to make my helper. In UI for MVC It looked like this

public static WindowBuilder KendoWindow(this HtmlHelper helper, string name, string titleResKey, string dataRequestUrl = null, int? minWidth = null, int? minHeight = null, int? maxWidth = null, int? maxHeight = null, string onRefreshEvent = null)
        {
            var attrib = new Dictionary<string, object>();

            var window = helper.Kendo()
            .Window()
            .Name(name)
            .Title(titleResKey)
            .Draggable()
            .Actions(action => action.Close())
            .Animation(true)
            .Events(x => x.Activate("onKendoWindowActivate").Close("onKendoWindowClose"))
            .Modal(true)
            .Visible(false).AutoFocus(true);

return window;

}

But in the version for Net Core I do not have a reference helper.Kendo()

How can I do this now? Thank you

 

 

Dimitar
Telerik team
 answered on 31 Jul 2018
1 answer
100 views

Hi,

In my current implementation I have a page that is set up as stated in my previous post:
https://www.telerik.com/forums/autobind(false)-not-adding-a-new-row-when-grid-is-empty 

The above implementation sets up my datasource in the initialization of the grid and populates the grid with the data from the API.

What am I trying to achieve?

I am looking for a way to design 2 sets of datasources and apply the selected datasource to the grid based on a button click.

My current attempt looks like this:

@(Html.Kendo()
                .Grid<CoreMVC.ViewModels.SysuserViewModel>()
                .Name("grid")
                .Columns(columns =>
                {
                   ...

                })
                    .ToolBar(toolbar =>
                    {
                        toolbar.Create();
                        toolbar.Save();
             })
                .Editable(editable => editable.Mode(GridEditMode.InLine))
                .Filterable(filterable => filterable
                            .Extra(false)
                            .Operators(operators => operators
                                .ForString(str => str.Clear()
                                    .StartsWith("Starts with")
                                    .EndsWith("Ends with")
                                    .IsEqualTo("Is equal to")
                                    .IsNotEqualTo("Is not equal to")
                                    .Contains("Contains")
                                    .DoesNotContain("Doesn't contain")
                                ))
                            )
                .Pageable()
                .Navigatable()
                .ColumnMenu()
                .AutoBind(false)
                .Sortable()
                .Editable()
                .Resizable(resizable => resizable.Columns(true))
                .Scrollable(scr => scr.Height(800))
                .Reorderable(reorderable => reorderable.Columns(true))
                .DataSource("dataSource1")
)

 

@(Html.Kendo().DataSource<CoreMVC.ViewModels.SysuserViewModel>()
        .Name("dataSource1")
        .Ajax(dataSource => dataSource
           .PageSize(10)
           .Model(m =>
           {
               m.Id(p => p.userid);
               m.Field(p => p.role).DefaultValue(ViewData["defaultRole"] as CoreMVC.ViewModels.RoleViewModel);
           })

           //.Events(ev => ev

           //.Error("error_handler")
           //.Push("onPush")
           //.Sync("sync_handler")

           //)
           .Read(read => read
           .Url(Base.APIHostAddress + "/api/user/getall")
           .Type(HttpVerbs.Get)
           )
        )
)

This datasource successfully hits my API and returns JSON but the grid is not populated and there is no error message. Is this because I am not specifying a DataType as "json" on the datasource? If so, I am unable to find the correct place to state the datatype with this datasource.

The return of the API looks like this: "return Json(userList);" where userList isa  List<userDTO>.

I have commented out the events, but i am also receiving errors on the events saying that the methods cannot be found even though they are present and work when I use the implementation from the forum post i created stated above.

Thank you in advance!

Tsvetina
Telerik team
 answered on 27 Jul 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
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?