Telerik Forums
UI for ASP.NET Core Forum
5 answers
503 views

Hi All,

I have an endpoint that accepts either params username/password or Authorization Header.

I can populate my kendoDropDownList w/o issue using params. (see code below)

var dataSourceAuthorization = new kendo.data.DataSource({
    transport: {
        type: "GET"
        }
});
 
$("#userList").kendoDropDownList({
    dataTextField: "userId",
    dataValueField: "userNumber",
    dataSource: dataSourceAuthorization,
    optionLabel: "Select User"
});

 

but when I use Authorization header, I'm getting > GET https://restsandbox.azurewebsites.net/services/rest/gettestdata 401 (Unauthorized)

(see code below)

var dataSourceAuthorization = new kendo.data.DataSource({
    transport: {
        type: "GET",
        beforeSend: function (res) {
            res.setRequestHeader('Authorization', 'Bearer Te$t_T0ken');
        }
    }
});
 
$("#userList").kendoDropDownList({
    dataTextField: "userId",
    dataValueField: "userNumber",
    dataSource: dataSourceAuthorization,
    optionLabel: "Select User"
});

 

Please note that using same Authorization header value with Postman, its working fine. (See attached)

 

Did I use sendBefore incorrectly? Any idea why its not working with Headers?

Thanks!

Ryan

Aleksandar
Telerik team
 answered on 01 Jun 2020
6 answers
2.3K+ views

Under MVC 5 this worked:

 

@(Html.Kendo().TabStrip()
   .Name("tabstrip")
   .SelectedIndex(0)
   .Items(tabstrip =>
       {
            tabstrip.Add().Text("Add Children")
               .Enabled(false)
               .Content(m => Html.Partial("_FamilyIntakeStep3", m))
               ;

})

})

 

But under ASP.Net Core, this no longer works.  Instead I am getting the class as a string.  I am pretty sure this is happening because the call is asynchronous, which means I should add in the await keyword.  But I have no idea how to do this in the kendo tabstrip.

 

Or perhaps there is a completely different solution that I should try?

Dan
Top achievements
Rank 1
Veteran
 answered on 29 May 2020
6 answers
896 views

I have Add Child/Update/Delete functionality in the columns of my TreeList.  However, I don't want to display Update or Delete on my root node.  I expected to do this using the Hidden attribute but my attempt doesn't work.  How do I accomplish this?

My failed attempt:

@(Html.Kendo().TreeList<GsiPortal.Models.Group>()
  .Name("treelist")
  .Columns(columns =>
  {
      columns.Add().Field(e => e.Name).Width(220).TemplateId("icon-template");
      columns.Add().Field(e => e.Description);
      columns.Add().Field(e => e.CurrentStatus.Name).Title(nameof(Group.Status));
      columns.Add().Field(e => e.AddTimestamp).Width(220).Title("Timestamp").Format("{0:MMMM d, yyyy}");
      columns.Add().Command(c => { c.CreateChild().Text("Add"); }).HtmlAttributes(new { style = "text-align: center;" });
      columns.Add().Command(c => { c.Edit(); }).HtmlAttributes(new { style = "text-align: center;" }).Hidden(x => x.CustomerInfo != null);
      columns.Add().Command(c => { c.Destroy(); }).HtmlAttributes(new { style = "text-align: center;" }).Hidden(x => x.CustomerInfo != null);
  })
  .Editable(e => e.Mode(TreeListEditMode.PopUp).TemplateName("GroupEdit"))
  .Selectable(selectable => selectable.Mode(TreeListSelectionMode.Single))
  .DataSource(dataSource => dataSource
      .ServerOperation(false)
      .Create(create => create.Action("CreateJson", "Groups"))
      .Read(read => read.Action("AllJson", "Groups").Data("groupsRead"))
      .Update(update => update.Action("UpdateJson", "Groups"))
      .Destroy(delete => delete.Action("DestroyJson", "Groups"))
      .Model(m =>
      {
          m.Id(f => f.Id);
          m.ParentId(f => f.ParentId);
          m.Expanded(true);
          m.Field(f => f.Name);
          m.Field(f => f.Description);
          m.Field(f => f.AddTimestamp).Editable(false);
      })
      .Events(events =>
      {
          events.Error("onError");
      })
  ))
Sivaramakrishna Reddy
Top achievements
Rank 1
Veteran
 answered on 29 May 2020
1 answer
131 views

When user try to add new items I have to validate the item by calling the service and if its valid I need to add it to the list. I am planning to use the noDataTemplate for this, but not sure how to validate the user entry and sow the option to add only when it is valid. Could you please advise on that

To explain it better, in multiselect I am displaying the List of existing available users in the list. but they can valid users outside the list b checking whether it's valid user or not by calling some external service. if it is valid I want to show the option add that item.

I tried creating noDataTemplate, when I use it as normal  javascript(with out ajax callback) like below it's working as expected

<script id="noDataTemplate" type="text/x-kendo-tmpl">
        # var value = instance.input.val(); #
        # var id = instance.element[0].id; #
        # if(value == 'validUser') {#
        <div>
            do you want to add the user - <span style="font-weight:bold">'#: value #' </span>?
        </div>
        <br />
        <button class="k-button" onclick="addnew('#: id #', '#: value #')" ontouchend="addnew('#: id #', '#: value #')">add new item</button>
        # } else { console.log('value:  ' + data);#
        <div>
            user does not exists
        </div>
        # }  #
    </script>

But as I have to validate user I used the template as below, it's executing without error, but the Html is not rendering in the template. it's showing the notemplate area, but there is no text inside it. (not even showing no data found). looks it's the issue because of callback. Please let me know how to solve this issue.

<script id="noDataTemplate" type="text/x-kendo-tmpl">
        # var value = instance.input.val(); #
        # var id = instance.element[0].id; #
        # $.post("@Url.Action("validateuser", "AdminWorkflow")", {alias: instance.input.val()}, function(data){#
        # if(data) {
               <div>
            do you want to add the user - <span style="font-weight:bold">'#: value #' </span>?
        </div>
        <br />
        <button class="k-button" onclick="addnew('#: id #', '#: value #')" ontouchend="addnew('#: id #', '#: value #')">add new item</button>
        # } else { console.log('value:  ' + data);#
        <div>
            user does not exists test
        </div>
        # }  #
        #})  #
    </script>

Aleksandar
Telerik team
 answered on 29 May 2020
2 answers
426 views

On my grid I just want to display an alternate message than the stock one so I added the following but it doesn't honor the text I assigned to it.

 

.Editable(editable => editable.Mode(GridEditMode.InLine).ConfirmDelete("My custom delete confirm message"))

Scott
Top achievements
Rank 1
Veteran
 answered on 27 May 2020
1 answer
309 views

I have this stepper that I am forcing the selection to index 2. 

-- this is the script part

$(document).ready(function () {
        var stepper = $("#meetingSessionStepper").data("kendoStepper");
        stepper.select(2);
        
    });

function onSelectStep(e) {

       ----- This is not triggered when the page loads
       
    }

 

--- this is the control

 @(Html.Kendo().Stepper()
            .Name("meetingSessionStepper")
            .Linear(false)
            .Orientation(StepperOrientationType.Horizontal)
            .Steps(s =>
            {
                s.Add().Label("Preparation");
                s.Add().Label("Start Lesson");
                s.Add().Label("Attendance");
                s.Add().Label("Session Notes");
                s.Add().Label("End Lesson");
            })
            .Events(events => events.Select("onSelectStep"))
    )

But for some reason, my event method onSelectStep is not being triggered when the page loads. This method though is triggered when manually clicking the step from the stepper control.

 

Anton Mironov
Telerik team
 answered on 27 May 2020
8 answers
240 views
Document Processing Libraries support .Net Core 2.0
Petar
Telerik team
 answered on 27 May 2020
7 answers
2.4K+ views

Can you tell me how to template my IsActive column to a CheckBox column.  I also want the option of having it show text Yes/No instead of True/False.

        @(Html.Kendo().Grid<Person>()
                    .Name("grid")
                    .Columns(columns =>
                    {
                        columns.Command(command => command
                          .Custom("Detail")
                          .Click("goDetail"))
                          .Width(Glossary.Portal.ButtonWidth);
                        columns.Bound(p => p.FirstName)
                          .Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")
                              .ShowOperators(false)
                              .SuggestionOperator(FilterType.Contains)));
                        columns.Bound(p => p.LastName)
                          .Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")
                              .ShowOperators(false)
                              .SuggestionOperator(FilterType.Contains)));
                        columns.Bound(p => p.IsActive);
                    })
                    .Pageable()
                    .Sortable()
                    .Scrollable()
                    .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
                    .HtmlAttributes(new { style = "height:550px;" })
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .PageSize(20)
                        .Read(read => read.Action("IndexJson", "Users")
                        .Data("getData"))
              ))
 
        <script type="text/javascript">
 
            function getData() {
                return @Html.Raw(Model.GetIndexData());
            }
 
...
Ivan Danchev
Telerik team
 answered on 27 May 2020
7 answers
511 views

I am using the grid to display some fields. one of the field is to display the List of usernames. I am able to display the List of user names using ClientTemplate. But Iam facing the issue while editing or adding new row. While displaying I bind the column with usenameList and pass the same in function used for ClientTemplate. While display it's working fine. but when I click on Edit/Add New it's throwing javascript error as usenameList is undefined. my requirement to to display the lit of users with option to delete them and a buuton add new user. I didn't find he option to crate a templete to sho while editing like ClientTemplate for dispaly.

 

.Columns(columns =>
    {
        columns.Bound(p => p.Name);
        columns.Bound(p => p.someId);
        columns.Bound(p => p.discontinue).
        columns.Bound(p => p.userList).Title("Approvers").ClientTemplate("#=userTemplate(userList)#").Sortable(false);
        columns.Command(command => { command.Edit().UpdateText("Save"); command.Destroy(); })
    })

 

function userTemplate(data) {
        this.approvers = "";
        data.forEach(element => {
            this.approvers += "<tr> <td style='width: 30 %; font-weight: bold'>" + element.userID+ "</td> <td>" + element.Display Name +</td></tr>";
        });
        return "<table>" + this.approvers + "</table>";
    }

The Edit Column in grid looks like the attched. Please let me know how to do it

 

Nikolay
Telerik team
 answered on 27 May 2020
3 answers
2.1K+ views

I have found a couple solutions online if you want to use a detail view under a row in the grid control, but that is not exactly what I am looking for. I have a ASP.NET Core 2 solution and I want to be able to display "tags" that can be links in the column itself without having to do a detail drill-in. Nothing I have done to this point has worked. 

The ArtcleViewModel has a List property of Tags. Is this impossible or am I missing something? Any help to create links per tag is appreciated without the use of a drill in detail view that the user would need to click to see.

@(Html.Kendo().Grid<MBIntranet.Web.ViewModel.ArticleViewModel>()
            .Name("grid")
            .Columns(columns =>
            {
                columns.Bound(c => c.Title).Title("Title");
                columns.Bound(c => c.User.DisplayName).Title("Author");
                columns.Bound(c => c)
                    .ClientTemplate("#= data.Tags[0].Name #")
                    .Title("Tags");
Alex Hajigeorgieva
Telerik team
 answered on 26 May 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?