Telerik Forums
UI for ASP.NET MVC Forum
2 answers
1.9K+ views

Hello, 

I want to Fetch all files in a local Folder (Directory) and populate file names and present them in my view page as a drop down list.

taking the name of the file selected and save it in my table as a string value.

any suggestions please ?

Thank you in advance.

Wassim
Top achievements
Rank 1
Veteran
Iron
 answered on 04 Jun 2021
1 answer
119 views

I check on site some examples for drag-drop in diagram bug that is only available for ASP.Net AJAX but I need them in ASP.NET MVC. I attached a link as well for reference.

https://demos.telerik.com/aspnet-ajax/diagram/examples/interactions/defaultcs.aspx

So, anybody helps me that it is available for ASP.NET MVC or not.

Ivan Danchev
Telerik team
 answered on 03 Jun 2021
1 answer
170 views

When I dynamically add in a column and set the title the order in the column filter is wrong. Clicking on "1" in the Column filter disabled "4" which is the 5th column in the loop. However if I remove the Title, then it works as expected. I need to set the Title for my usage. Originally I tried setting the title to an actual text value but that is when I found the order was messed up.


            @(Html.Kendo().Grid<InventoryItemViewModel>()
    .Name("InventoryItemGrid")
    .Columns(columns =>
    {
    columns.Bound(c => c.InventoryItemId).Title("ID").ClientTemplate("#=kendo.toString(InventoryItemId, '000000')#").Media("(min-width: 1200px)").Filterable(ftb => ftb.Multi(true));
    columns.Bound(c => c.Name).Media("(min-width: 1200px)").Filterable(ftb => ftb.Multi(true));
    columns.Bound(c => c.Description).Title("Description").Media("(min-width: 1200px)").Filterable(ftb => ftb.Multi(true));
    columns.Bound(c => c.InventoryItemTypeName).Title("Type").Media("(min-width: 1200px)").Filterable(ftb => ftb.Multi(true));
    columns.Bound(c => c.WetTonnes).ClientTemplate("<span class='source-#=WetTonnesSource#'>#=WetTonnes#</span>").Media("(min-width: 1200px)");
    columns.Bound(c => c.MoisturePercent).ClientTemplate("<span class='source-#=MoisturePercentSource#'>#=MoisturePercent#</span>").Media("(min-width: 1200px)");
    columns.Bound(c => c.CoarseFineRatio).ClientTemplate("<span class='source-#CoarseFineRatioSource#'>#=CoarseFineRatio#</span>").Title("Coarse Percentage").Media("(min-width: 1200px)");
    for (int x = 0; x < 6; x++)
    {
        columns.Bound(c => x).Title(x.ToString()).ClientTemplate(x.ToString());
    }


    columns.Bound(c => c.IsBlended).Media("(min-width: 1200px)").Filterable(ftb => ftb.Multi(true));
    columns.Bound(c => c.Status).ClientTemplate("#=statusTemplate(data)#").Media("(min-width: 1200px)").Filterable(ftb => ftb.Multi(true));

    columns.Bound(c => c.CreatedDate).Media("(min-width: 1200px)").Format("{0:g}").Hidden(true);
    columns.Bound(c => c.CreatedBy).Media("(min-width: 1200px)").Hidden(true);
    columns.Bound(c => c.LastUpdatedDate).Media("(min-width: 1200px)").Format("{0:g}").Hidden(true);
    columns.Bound(c => c.LastUpdatedBy).Media("(min-width: 1200px)").Hidden(true);
    columns.Template(@<text></text>).ClientTemplate("#=resColTemplate(data)#").Title("Details").Media("(max-width: 1200px)");
    })
    .Sortable()
    .Scrollable(s=>s.Height("auto"))
    .Filterable()
    .ColumnMenu(c=>c.Columns(true))
    .Excel(excel => excel
        .FileName("Inventory Item Export.xlsx")
        .Filterable(true)
        .AllPages(true)
        .ProxyURL(Url.Action("Excel_Export_Save", "InventoryItems"))
    )
    .ToolBar(t=>
    {

        t.Template(@<text>
            <div class="toolbar">
                 <label class="k-grid-title-label">Items</label>
<div class="k-grid-toolbar-btns">
<button type="button" class="btn btn-secondary btn-sm" id="ExcludeFilter" data-exclude-state="excluded">
<i class="fa fa-filter" aria-hidden="true"></i>
Exclude Archived
</button>
                     <button id="export" class="btn btn-secondary btn-sm"><i class="fas fa-file-excel"></i></button>
@if (PLS.Library.Authorize.AuthorizeUser(PLS.Models.Enum.AccessLevel.Create, PLS.Models.Enum.SystemSection.Inventory))
{
<a class="btn btn-primary btn-sm"  href="@Url.Action("Create", "InventoryItems", new { Area = "Inventory" })">
Create
</a>
}
</div>
<div class="k-grid-toolbar-search">
<span class="k-textbox k-grid-search k-display-flex">
<input autocomplete="off" placeholder="Search..." title="Search..." class="k-input">
<span class="k-input-icon"><i class="fa fa-search" aria-hidden="true"></i></span>
</span>
</div>
           </div>
            </text>);
    })
    .Search(search =>
    {
        search.Field(f => f.InventoryItemId);
        search.Field(f => f.Name);
        search.Field(f => f.Description);
        search.Field(f => f.InventoryItemTypeName);
        search.Field(f => f.Status);
        search.Field(f => f.WetTonnes);
        search.Field(f => f.CoarseFineRatio);
        search.Field(f => f.MoisturePercent);
    })
    .Pageable(pageable => pageable
        .Refresh(true)
        .PageSizes(true)
        .ButtonCount(5)
    )
    .Selectable(selectable =>
    {
        selectable.Mode(GridSelectionMode.Single);
        selectable.Type(GridSelectionType.Row);
    })
    .Resizable(resize => resize.Columns(true))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("InventoryItems_Read", "InventoryItems"))
        .Sort(sort =>
        {
            sort.Add(f => f.StatusId).Ascending();
            sort.Add(f => f.CreatedDate).Ascending();
        })
        .PageSize(10).ServerOperation(false)
        .Filter(f => f.Add(x => x.Status).IsNotEqualTo("Archived"))
    )
)


 

Anton Mironov
Telerik team
 answered on 02 Jun 2021
1 answer
911 views

About 40% of the time our build fails with a bunch of errors like below


 Response status code does not indicate success: 500 (Internal Server Error).
  Retrying 'FindPackagesByIdAsyncCore' for source 'https://nuget.telerik.com/nuget/FindPackagesById()?id='System.Diagnostics.StackTrace'&semVerLevel=2.0.0'.
  Response status code does not indicate success: 500 (Internal Server Error).
  Retrying 'FindPackagesByIdAsyncCore' for source 'https://nuget.telerik.com/nuget/FindPackagesById()?id='System.Xml.XmlDocument'&semVerLevel=2.0.0'.
  Response status code does not indicate success: 500 (Internal Server Error).
  Retrying 'FindPackagesByIdAsyncCore' for source 'https://nuget.telerik.com/nuget/FindPackagesById()?id='System.Xml.XDocument'&semVerLevel=2.0.0'.
  Response status code does not indicate success: 500 (Internal Server Error).
  Retrying 'FindPackagesByIdAsyncCore' for source 'https://nuget.telerik.com/nuget/FindPackagesById()?id='System.Reflection.Emit.ILGeneration'&semVerLevel=2.0.0'.
  Response status code does not indicate success: 500 (Internal Server Error).
  Retrying 'FindPackagesByIdAsyncCore' for source 'https://nuget.telerik.com/nuget/FindPackagesById()?id='System.Composition.TypedParts'&semVerLevel=2.0.0'.
  Response status code does not indicate success: 500 (Internal Server Error).
  Retrying 'FindPackagesByIdAsyncCore' for source 'https://nuget.telerik.com/nuget/FindPackagesById()?id='System.Configuration.ConfigurationManager'&semVerLevel=2.0.0'.
  Response status code does not indicate success: 500 (Internal Server Error).

Note it doesnt always happen. Any idea how to troubleshoot this? 

Thanks

 

Ivan Danchev
Telerik team
 answered on 01 Jun 2021
1 answer
515 views

I have a grid which has ServerOperations set to TRUE.  The total number of records is very large, so we're only displaying 20 at a time.  One of the columns contains a filter dropdown containing a list of checkboxes for selecting specific values to filter on.  I want the Filter dropdown to include ALL possible values for the user to choose from...not just the ones that are returned for each page.  Is there a recommended approach for doing this?  (I have provided the grid initialization code below...)

 

                @(Html.Kendo().Grid<MemberPopCodeModel>()
                 .AutoBind(false)
                 .Name("MemberPopCodeGrid")
                 .HtmlAttributes(new { @class = "editor-grid" })
                 .Columns(columns =>
                 {
                     columns.Bound(e => e.PopCode.FormattedText).Filterable(ftb => ftb.Multi(true).CheckAll(true).Search(true).BindTo(memberPopCodeListItems)).Sortable(true)
                            .HtmlAttributes(new { @class = "ellipsis-nowrap", title = "#= PopCode.FormattedText #" })
                            .HeaderHtmlAttributes(new { @title = HtmlLocaleHelper.GetLabelTooltip(ManagedCareConstants.Localization.Labels.Fields.PopCode).ToString() })
                            .Title(HtmlLocaleHelper.GetLabelText(ManagedCareConstants.Localization.Labels.Fields.PopCode).ToHtmlString());
                     columns.Bound(e => e.EffectiveDate).ClientTemplate("#= formatReceivedDate(StrEffectiveDate) #").Filterable(true).Sortable(true)
                             .HtmlAttributes(new { @class = "ellipsis-nowrap", title = "#= kendo.format('{0:d}', kendo.parseDate(StrEffectiveDate)) #" })
                             .Filterable(a => a.UI("datePicker"))
                             .HeaderHtmlAttributes(new { @title = HtmlLocaleHelper.GetLabelTooltip(ManagedCareConstants.Localization.Labels.Fields.MemberPopCodeEffectiveDate).ToString() })
                             .Title(HtmlLocaleHelper.GetLabelText(ManagedCareConstants.Localization.Labels.Fields.MemberPopCodeEffectiveDate).ToHtmlString());
                     columns.Bound(e => e.EndDate).ClientTemplate("#= formatReceivedDate(StrEndDate) #").Filterable(true).Sortable(true)
                             .HtmlAttributes(new { @class = "ellipsis-nowrap", title = "#= kendo.format('{0:d}', kendo.parseDate(StrEndDate)) #" })
                             .Filterable(a => a.UI("datePicker"))
                             .HeaderHtmlAttributes(new { @title = HtmlLocaleHelper.GetLabelTooltip(ManagedCareConstants.Localization.Labels.Fields.MemberPopCodeEndDate).ToString() })
                             .Title(HtmlLocaleHelper.GetLabelText(ManagedCareConstants.Localization.Labels.Fields.MemberPopCodeEndDate).ToHtmlString());
                     columns.Bound(e => e.Status).Filterable(ftb => ftb.Multi(true).CheckAll(true).BindTo(new[]{
                                                  new { Status = statusCurrent },
                                                  new { Status = statusFuture },
                                                  new { Status = statusPast },
                                                  new { Status = statusInvalid }
})
                     ).Sortable(false)
                             .HeaderHtmlAttributes(new { @title = HtmlLocaleHelper.GetLabelTooltip(ManagedCareConstants.Localization.Labels.Fields.GlobalPeriodStatus).ToString() })
                             .Title(HtmlLocaleHelper.GetLabelText(ManagedCareConstants.Localization.Labels.Fields.GlobalPeriodStatus).ToHtmlString());
                 })
.Scrollable()
.Resizable(r => r.Columns(true))
.Sortable(s => s
.AllowUnsort(false)
.SortMode(GridSortMode.SingleColumn))
.Events(e => e
.DataBound("popCodeGridDataBound")
.DataBinding("popCodeGridDataBinding")
.FilterMenuInit("onFilterMenuInit")
)
.Filterable(filterable => filterable
.Extra(false)
.Messages(msg => msg.Clear(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.Operators.Clear).ToString()))
.Operators(operators => operators
.ForDate(date => date.Clear()
    .IsEqualTo(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.Operators.EqualTo).ToString())
    .IsGreaterThanOrEqualTo(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.Operators.GreaterThanOrEqualTo).ToString())
    .IsLessThanOrEqualTo(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.Operators.LessThanOrEqualTo).ToString())
    )
)
)
.DataSource(d => d.Ajax()
.ServerOperation(true)
.Events(e => e.Error("onWebApiError"))
.Read(read => read.Url(
ContextHelper.BuildWebApiUrl(ManagedCareConstants.WebApi.Controllers.ManagedCare, ManagedCareConstants.WebApi.Actions.GetMemberPopCode)
).Type(HttpVerbs.Get)
)
.Model(m => m.Id(e => e.PopCodeId))
.Sort(s =>
{
    s.Add("EndDate").Descending();
    s.Add("EffectiveDate").Descending();
    s.Add("PopCode.FormattedText").Ascending();
})
)
.Pageable(pageable => pageable
    .Refresh(true)
    .PageSizes(true)
    .ButtonCount(3)
    .Messages(messages =>
    {
        messages.ItemsPerPage(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.ItemsPerPage).ToString().Trim());
        messages.Next(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.NextPage).ToString().Trim());
        messages.Last(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.LastPage).ToString().Trim());
        messages.Previous(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.PreviousPage).ToString().Trim());
        messages.First(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.FirstPage).ToString().Trim());
        messages.Refresh(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.Refresh).ToString().Trim());
        messages.Display(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.Display).ToString().Trim());
        messages.MorePages(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.MorePages).ToString().Trim());
        messages.Empty(HtmlLocaleHelper.GetLabelText(CoreConstants.Localization.Labels.Grid.Empty).ToString().Trim());
    })
)
.Resizable(r => r.Columns(true))
.Scrollable()
.Selectable(se => se.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
.Sortable(s => s
.AllowUnsort(false)
.SortMode(GridSortMode.SingleColumn)
)
.Selectable(se => se.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
    )
Anton Mironov
Telerik team
 answered on 31 May 2021
2 answers
589 views
I am trying perform batch editing in kendo grid.

My remote validation is not working properly

In Page source it show all the attributes related to remote validation

<input data-bind="value:Name" class="text-box single-line" data-val="true" data-val-length="Name cannot exceed 100 characters." data-val-length-max="100" data-val-remote="Option name already exist" data-val-remote-additionalfields="*.Name,*.Id,*.ParentOptionId" data-val-remote-url="/Options/OptionNameUnique" data-val-required="The Name field is required." id="Name" name="Name" value="" type="text">


Still remote validation not getting called.
Anton Mironov
Telerik team
 answered on 31 May 2021
1 answer
216 views


@using EconExcelExtender.Classes

@model List<PocoAttributeDetail>

@{
    var modelName = ViewBag.ModelName;
    var companySite = ViewBag.CompanySite;
    var inUse = ViewBag.InUse;
    int hasBeenDownloaded = (int)ViewBag.HasBeenDownloaded;
}

<div id="mdlattributeMaintenance" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-xl" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Attribute Maintenance</h5>
            </div>
            <div id="attributeMaintenanceBody" class="modal-body">

            </div>
        </div>
    </div>
</div>

@if (hasBeenDownloaded == (int)Enums.AttributeOptionDownloadStatus.InAttributesAndOptions)
{

    <div class="row mt-2">
        <div class="col-12 text-center">
            <h6>Attributes for Model @modelName only exist in the Attribute And Options Table</h6>
            <h6>They must be downloaded before adding new records, or editing existing records can take place.</h6>
        </div>
        <div class="col-12 text-center">
            <button type="button" id="btnDownloadAttributes" onclick="" data-text="Download Attributes" class="btn btn-danger form-control btnDownloadAttributes">Download Attributes</button>
        </div>
    </div>


}

@if (hasBeenDownloaded == (int)Enums.AttributeOptionDownloadStatus.None)
{

    <div class="row mt-2">
        <div class="col-12 text-center">
            <h6>There are no attributes for Model @modelName found on the database</h6>
            <h6>They must be entered using this form.</h6>
        </div>
    </div>

}


@if (Model != null)
{

    <div class="mt-2">
        @(Html.Kendo().Grid(Model)
            .Name("grid")
            .TableHtmlAttributes(new {@style="font-size:smaller"})
            .Columns(columns => {


                columns.Bound(p => p.AttributeDetailID).Title("Attribute ID").Width(105);
                columns.Bound(p => p.AttributeCode).Title("Attribute Code").Width(105);
                columns.Bound(p => p.AttributeName).Title("Attribute Name").Width(150);
                columns.Bound(p => p.InputOutput).Title("Input/Output").Width(105);
                columns.Bound(p => p.Type).Title("Type").Width(105);
                columns.Bound(p => p.IsRange).Title("Is Range").Width(80)
                    .ClientTemplate("#= IsRange ? 'Yes' : 'No' #");
                columns.Bound(p => p.HasLabels).Title("Has Range").Width(80)
                    .ClientTemplate("#= HasLabels ? 'Yes' : 'No' #");
                columns.Bound(p => p.InUse).Title("In Use").Width(80)
                    .ClientTemplate("#= InUse ? 'Yes' : 'No' #");
                
                 columns.Command(commands =>
 {
 commands.Edit();
 commands.Destroy();
 });


            })
                .HtmlAttributes(new { style = "height: 550px;" })

                .Sortable()
    .Scrollable(scr=>scr.Height(430))
    .Filterable()
    .Pageable()

    //.Editable(editable => editable.Mode(GridEditMode.PopUp))


    .DataSource(ds => {
        ds.Ajax()
        .Model(model => model.Id(p => p.AttributeDetailID))

     .ServerOperation(false);


        ;



    })
    )
    </div>

}

@using (Ajax.BeginForm("MaintainAttribute", "AttributesAndOptions", null, new AjaxOptions
{
    UpdateTargetId = "attributeMaintenanceBody",
    InsertionMode = InsertionMode.Replace,
    OnComplete = "$('#mdlattributeMaintenance').modal('show');  ShowSpinner(null, '', 'hide'); ",
    HttpMethod = "Post"

}, new { @id = "frmMaintModelAttributes" }))
{

    <input type="hidden" id="itemModel" name="ModelName" value="@modelName" />
    <input type="hidden" id="itemID" name="ItemID" />
}

@using (Ajax.BeginForm("DownloadAttributes", "AttributesAndOptions", null, new AjaxOptions
{
    UpdateTargetId = "maintenancediv",
    InsertionMode = InsertionMode.Replace,
    OnComplete = "SetUpTable('#tblDisplay');ShowSpinner(null, '', 'hide'); ",
    HttpMethod = "Post"

}, new { @id = "frmDownloadAttributes" }))
{

    <input type="hidden" id="optionModel" name="ModelName" value="@modelName" />
    <input type="hidden" id="optionCompany" name="CompanySite" value="@companySite" />

}

Hi,

I am trying to do inline editing on a local datasource provided from a controller source. 

When I add the command button I get the following error:

System.InvalidOperationException: 'The parameter conversion from type 'System.String' to type 'System.Boolean' failed. See the inner exception for more information.'

This is the error message: 		"-1 is not a valid value for Boolean."


I'm wondering what I am doing wrong.

 

Thanks

 

Sean

Anton Mironov
Telerik team
 answered on 31 May 2021
4 answers
1.0K+ views

I use a kendo Splitter with 2 vertical panes (top-pane and bottom-pane).
Inside the top-pane .Content( ), I have a Kendo TabStrip with 3 tabs. Inside the bottom-pane .Content( ), I have a DropDownList / textbox controls and one input button "Save".
When the Main View page loads, my Main Controller Action retrieves the data and return the MainViewModel for my DropDownList / textbox controls and determines which Tab to select (ie show) to the user.

Here is my Kendo TabStrip on my main view with the MainViewModel

 

01.@(Html.Kendo().TabStrip()
02.    .Name("WorksheetTabStrip")
03.    .Items(tabstrip =>
04.    {
05.        tabstrip.Add().Text("Condition 1")
06.            .Selected( Model.ConditionSelection == 1 ? true : false)
07.            .LoadContentFrom("ConditionAction", "Worksheet", new { invoiceID = Model.InvoiceID, tabNum = 1 })
08.            .ContentHtmlAttributes(new { style = "height:580px;" });
09. 
10.        tabstrip.Add().Text("Condition 2")
11.            .Selected(Model.ConditionSelection == 2 ? true : false)
12.            .LoadContentFrom("ConditionAction", "Worksheet", new { invoiceID = Model.InvoiceID, tabNum = 2 })
13.            .ContentHtmlAttributes(new { style = "height:580px;" });
14. 
15.        tabstrip.Add().Text("Condition 3")
16.            .Selected(Model.ConditionSelection == 3 ? true : false)
17.            .LoadContentFrom("ConditionAction", "Worksheet", new { invoiceID = Model.InvoiceID, tabNum = 3 })
18.            .ContentHtmlAttributes(new { style = "height:580px;" });
19. 
20.    })
21. 

 

Each of the tabStrip .LoadContentFrom( ) calls the action "ConditionAction" to load data in the tab's corresponding PartialView.

 

public ActionResult ConditionAction(int invoiceID, int tabNum)  {
      // ... get data for the corresponding Tab from database
      ConditionViewModel model = getDBdata();
      if (tabNum == 1)
             return PartialView("_Condition1", model);
      else if (tabNum == 2)
             return PartialView("_Condition2", model);
      else if (tabNum == 3)
             return PartialView("_Condition3", model);
       else
             return View("Error");
}

 

With the codes that I have so far,  displaying the right data for the appropriate tab contents works.

My problem is when user clicks on the "Save" button (at the bottom-pane), how do I read from the form data of the Tab that I want.

For example, user clicks "Tab 2" and types some inputs in Textboxes, then clicks the Save button. I just want to read the form in Tab2 and save its data. (form in Tab1 and Tab 3 are ignored) and additionally read the main form controls (DropdownList etc) and save as well all at the same time.

I was planning to do an Ajax call onClick of the Save button. But don't know how to read and pass the PartialViewModel to my Controller.

 

<input type="button" id="btnSave" name="btnSave" value="Save" class="btn btn-danger btn-default" style="width:100px;" />
 
<script type="text/javascript">
 
    $("#btnSave").click(function () {
        var formData = $("#formWorksheet").serialize();
 
        $.ajax({
            url: '@Url.Action("SaveWorksheet", "Worksheet")',
            type: "POST",
            cache: false,
            contentType: "application/x-www-form-urlencoded",
            data: formData,
            datatype: "json",
            success: function (response) {
                if (response.ok) {
                    alert(response.message);
                }
                else {
                    window.alert("Error: " + response.message);
                }
            },
            error: function (request, status, error) {
                alert("Unexpected Error! Please contact the Administrator.");
                alert(error);
            }
        });
    })
 
</script>

 

Any suggestion? 

 

Tony
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 27 May 2021
1 answer
545 views

I am using the kendo dropdown tree with vuejs. Below is how I am using the dropwdowntree.

The "mySelectedList" contains an array of IDs. If the form is being edited and the array is populated, this array will check items on the dropdowntree. This is as expected.

But as items from the dropdowntree are checked or unchecked by the user, this array "mySelectedList" does not get updated.

What is the proper way to bind a property to the dropdowntree?  How do I get "mySelectedList" to get updated as the user checks or unchecks items in the dropdowntree?

 

<dropdowntree 

:data-source="myDataSource"
autoClose: false
:checkboxes="true"
:check-all="true"
:placeholder="'Select from tree'"
dataTextField="text"
dataValueField="id"
v-model="mySelectedList"
>
</dropdowntree>

 

Petar
Telerik team
 answered on 27 May 2021
2 answers
602 views

I have been trying to get a scheduler to show simple events, but Im doing some wrong (probably something simple I'm not seeing.

I'm simply trying to return a list into the schedular based on the demo TaskViewModel

 

What am I doing wrong here.

 

Thanbks in advance

@(Html.Kendo().Scheduler<ShitTruckLibrary.Models.TaskViewModel>()
    .Name("scheduler")
    .Date(new DateTime(2021, 05, 10))
    .StartTime(new DateTime(2021, 5, 08, 00, 00, 00))
    .Height(600)
    .Views(views =>
    {
        views.DayView();
        views.WorkWeekView(workWeekView => workWeekView.Selected(true));
        views.WeekView();
        views.MonthView();
   
        views.AgendaView();
        views.TimelineView();
    })
    .Timezone("Etc/UTC")
    .Resources(resource =>
    {
        resource.Add(m => m.OwnerID)
            .Title("Owner")
            .DataTextField("Text")
            .DataValueField("Value")
            .DataColorField("Color")
            .BindTo(new[] {
                new { Text = "STC", Value = 1, Color = "#f8a398" } ,
                new { Text = "GTC", Value = 2, Color = "#51a0ed" }
               
            });
    })
    .DataSource(d => d
        .Model(m => {
            m.Id(f => f.TaskID);
            m.Field(f => f.Title).DefaultValue("No title");
            m.Field(f => f.OwnerID).DefaultValue(1);
            m.RecurrenceId(f => f.RecurrenceID);
        })
        .Read("Basic_Usage_Read", "WorkJobs")
   
        .Filter(filters =>
        {
            filters.Add(model => model.OwnerID).IsEqualTo(1).Or().IsEqualTo(2);
        })
    )
)

 public static  IList<TaskViewModel> GetAllJobs()
        {
            List<ContactJob> c = new List<ContactJob>();

            List<TaskViewModel> caLL = new List<TaskViewModel>();

            DataTable dt = new DataTable();

                    
            dt = SqlStore.CreateDataSet($@"SELECT cj.*,ForeName, SurName, CompanyName,Address1,Address2 FROM [dbo].[ContactJob]  cj join [dbo].[Contacts] c on cj.contactid = c.id order by JobDate desc").Tables[0];

            c = DataHelper.ConvertDataTable<ContactJob>(dt);
        


            foreach (ContactJob cc in c)
            {

                TaskViewModel vv = new TaskViewModel();
                vv.Start = DateTime.SpecifyKind(new DateTime(cc.JobDate.Year, cc.JobDate.Month, cc.JobDate.Day, 09, 00, 00),DateTimeKind.Local);
                vv.End = DateTime.SpecifyKind(new DateTime(cc.JobDate.Year, cc.JobDate.Month, cc.JobDate.Day, 10, 00, 00), DateTimeKind.Local);
                vv.Title = $"{cc.CompanyName} {cc.ForeName} {cc.SurName}".Trim();
                vv.Description = $"{cc.Address1} {cc.Address1}";
                vv.IsAllDay = true;
                vv.OwnerID = (cc.Type == "STC" ? 1 : 2);
                caLL.Add(vv);
            }


            return caLL;
        }

 

 public virtual JsonResult Basic_Usage_Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(Job.GetAllJobs().ToDataSourceResult(request));
        }

        public static  IList<TaskViewModel> GetAllJobs()
        {
            List<TaskViewModel> caLL = new List<TaskViewModel>();

            DataTable dt = SqlStore.CreateDataSet($@"SELECT cj.*,ForeName, SurName, CompanyName,Address1,Address2 FROM [dbo].[ContactJob]  cj join [dbo].[Contacts] c on cj.contactid = c.id order by JobDate desc").Tables[0];

            List<ContactJob> c = DataHelper.ConvertDataTable<ContactJob>(dt);

            foreach (ContactJob cc in c)
            {

                TaskViewModel vv = new TaskViewModel();
                vv.Start = DateTime.SpecifyKind(new DateTime(cc.JobDate.Year, cc.JobDate.Month, cc.JobDate.Day, 09, 00, 00),DateTimeKind.Local);
                vv.End = DateTime.SpecifyKind(new DateTime(cc.JobDate.Year, cc.JobDate.Month, cc.JobDate.Day, 10, 00, 00), DateTimeKind.Local);
                vv.Title = $"{cc.CompanyName} {cc.ForeName} {cc.SurName}".Trim();
                vv.Description = $"{cc.Address1} {cc.Address1}";
                vv.IsAllDay = true;
                vv.OwnerID = (cc.Type == "STC" ? 1 : 2);
                caLL.Add(vv);
            }


            return caLL;
        }

 

Ivan Danchev
Telerik team
 answered on 27 May 2021
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? 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?