Telerik Forums
UI for ASP.NET MVC Forum
1 answer
178 views

Hi,

When I add the option ".Selectable()" to my grid it does not render.  Any ideas?  Here is the code I am using to define the grid:

 

@(Html.Kendo().Grid<TEAMSV2.Models.NotYetInvoicedGridDTO>()
    .Name(Section + TabName + "Grid")
    .HtmlAttributes(new { style = "border-width: 0px;" })
    .DataSource(datasource => datasource
        .Ajax()
        .Read(read =>
        {
            read.Action("GetGridData", "TeamsV2", new { grid = Section + "_" + TabName }).Type(HttpVerbs.Post);
        })
        .Sort(sort => sort.Add("Created").Descending())
        .PageSize(120)
        .ServerOperation(false)
    )
    .Columns(columns =>
    {
        columns.Template(e => { }).Width(57).ClientTemplate(Html.Partial(ColumnTemplatePath + "IconsTemplate").ToHtmlString());
        columns.Bound(entry => entry.QuoteType).Title("Type").Width(100).Template(e => { }).ClientTemplate(Html.Partial(ColumnTemplatePath + "QuoteTypeTemplate").ToHtmlString());
        columns.Bound(entry => entry.Client).Title("Client").Width(100).Template(e => { }).ClientTemplate(Html.Partial(ColumnTemplatePath + "ClientTemplate").ToHtmlString());
        columns.Bound(entry => entry.Address).Title("Site").Template(e => { }).ClientTemplate(Html.Partial(ColumnTemplatePath + "SiteTemplate").ToHtmlString());
        columns.Bound(entry => entry.Postcode).Title("Postcode").Width(100).Template(e => { }).ClientTemplate(Html.Partial(ColumnTemplatePath + "PostcodeTemplate").ToHtmlString());
        columns.Bound(entry => entry.Project).Title("Project").Width(100).Template(e => { }).ClientTemplate(Html.Partial(ColumnTemplatePath + "ProjectTemplate").ToHtmlString());
        columns.Bound(entry => entry.JobNoFormatted).Title("Job No.").Width(80).Template(e => { }).ClientTemplate(Html.Partial(ColumnTemplatePath + "JobNoTemplate").ToHtmlString());
        columns.Bound(entry => entry.ClientOrderNo).Title("Client Order No.").Width(80).Template(e => { }).ClientTemplate(Html.Partial(ColumnTemplatePath + "ClientOrderNoTemplate").ToHtmlString());
        columns.Bound(entry => entry.Value).Title("Value").Width(100).Template(e => { }).ClientTemplate(Html.Partial(ColumnTemplatePath + "ValueTemplate").ToHtmlString());
        columns.Bound(entry => entry.Created).Title("Date").Width(80).Template(e => { }).ClientTemplate(Html.Partial(ColumnTemplatePath + "CreatedTemplate").ToHtmlString());
        columns.Template(e => { }).Title(" ").Width(35).ClientTemplate(Html.Partial(ColumnTemplatePath + "SelectorTemplate").ToHtmlString());
    })
    .ClientDetailTemplateId(Section + TabName + "DetailTemplate")
    .Sortable()
    .ToolBar(t => t
        .Template(Html.Partial(ColumnTemplatePath + "ToolsTemplate").ToHtmlString()))
    .Pageable(p => p
        .Refresh(true)
        .PageSizes(new[] { 15, 30, 60, 120 })
        .ButtonCount(5))
    .Events(e => e
        .ExcelExport("excelExport")
        .DataBound(Section + TabName + "Databound"))
    .Excel(ex => ex
        .FileName(Section + TabName + ".xlsx")
        .AllPages(true))
    .Selectable()
)

 

And here is the error I get from the Chrome console:

kendo.custom.min.js:4  - Uncaught TypeError: Cannot read property 'parseOptions' of undefined

We are using version 2015.1.429 of the kendo tools.

Thanks,

Mark.

Konstantin Dikov
Telerik team
 answered on 24 Aug 2016
2 answers
317 views

I have an MVC project that implements a database-driven questionnaire for legal contracts using Kendo MVC for ASP.NET version 2016.2.714. I am running into an odd rendering problem with the Tab Strip when I mix programmatic tab selection with manual tab selection.

The questionnaire is arranged into sections, sub-sections, and questions with answers. The user is expected to read a contract presented on the page and answer all of the “required” questions. Because there are about 100 questions on this thing (lawyers!), we allow the user to save a partially-entered questionnaire and return to it later. Because there are so many questions, there is a lot of vertical scrolling going on.

My page uses a vertically-arranged Kendo Splitter to separate the questionnaire from the contract document. Inside the Splitter, a Kendo Tab Strip organizes the questionnaire’s sections, which contain varying numbers of questions. Many partial views are used to render the questionnaire’s overall structure and content. A Kendo Progress Bar is used to display the user’s progress in answering all required questions, and we also prompt the user when they submit to remind them when the questionnaire isn’t 100% entered. If the user cancels that prompt, they can continue answering questions.

During testing, our customer observed that when “required” questions haven’t been answered, the user didn’t know where to look for a missing answer in the sea of questions. So I am implementing a mechanism to display the first unanswered question. I do this by scrolling the Kendo Tab’s DIV that is containing my questionnaire’s section content. So far, so good.

It’s all working perfectly except for one strange thing… the Tab Strip control. I knew that if the first unanswered question was on a different section (i.e. another Kendo Tab) than the one being viewed, that I would have to programmatically select that tab before scrolling its contents. Unfortunately, I have encountered a dramatic sizing anomaly in Kendo.

Out of the three questionnaire sections, one is very tall and the other two are short. I have discovered that if I am viewing either of the two short sections, then initiate the code to bring me to the first unanswered question (which is in the tallest section), the tall section shows just fine. But if I then click the Tab Strip to view the short section I just came from, it’s totally empty! The remaining short section is unaffected until I perform the same sequence of steps on that section. When I do, both short sections become zero pixels tall.

What I observed by using Internet Explorer’s DOM explorer was something strange happening to the “k-content” DIV in the Tab Strip when I use its “select()” method in JavaScript. For the tab I am currently viewing when my scripts runs, it gets a “height: auto” attribute added to it (where none existed before). The Tab Strip then switches to the desired tab as expected. But if I then manually click back to that original tab, its “height: auto” attribute is replaced with a “height: 0px” attribute and I see no content under that tab.

If I use the DOM explorer to remove the height attribute altogether, the content under that tab is restored to its normal appearance. But if I continue to click on tabs, the “height” attribute is immediately re-introduced.

None of this “height” attribute stuff happens if I click on the tabs manually. Only if I programmatically select one with script does the problem begin.
The Razor for my Tab Strip looks like this (see below). This code actually lives in a partial view that the Kendo Splitter presents, so basically the Tab is surrounded by the Splitter. I experimented with using no tab animation, to no avail.

        @(Html.Kendo().TabStrip()
            .Name("uxSections")
            .SelectedIndex(0)
            .Animation(a => a.Open(e => e.Fade(FadeDirection.In).Duration(AnimationDuration.Fast)))
            .Items(t =>
            {
                foreach (SectionViewModel sectionViewModel in Model.QuestionnaireRevision.Sections.OrderBy(s => s.SortOrder))
                {
                    t.Add()
                        .Text(sectionViewModel.Description)
                        .HtmlAttributes(new
                        {
                            id = $"uxSectionTab{sectionViewModel.SectionId}"
                        })
                        .Content(Html.Partial("_QuestionnaireSection", sectionViewModel).ToHtmlString());
                }
            })
        )

I tried stripping my JavaScript code down to the barest essentials (and hard-coded stuff just in case), and what I was left with consists of the following JavaScript statements. Section 2 is the tall section I am switching to. I removed all the code that tries scrolling.

        var sectionId = 2;
        var tabStrip = $("#uxSections").kendoTabStrip().data("kendoTabStrip");
        var item = tabStrip.tabGroup.find("#uxSectionTab" + sectionId);
        tabStrip.select(item.index());

If I click on one of the short sections and trigger this code (which takes me to the tall section), then when I manually click back on the short section’s tab, its contents are zero pixels tall.

Jonathan
Top achievements
Rank 1
 answered on 23 Aug 2016
5 answers
1.0K+ views

I have a function that takes an id of a node, and expands the treeview so the node is showing. This is necessary as I need to refresh the treeview as items are added and edited.

I'm loading all the data in one go, from am AJAX call.

The code works when fired from a button, however I need it to be fired once the treeview data has finished loading. Unfortunately the onDataBound event seems to fire multiple times, depending on how many nodes the treeview contains. I did try using the datasource requestEnd event, however this seems to fire before the onDataBound events.

How can I detect that the treeview data has loaded, and the treeview is ready to have my expand function called?

The treeview definition is:-

@(Html.Kendo().TreeView()
                   .Name("Treeview")
                   .ExpandAll(false)
                   .LoadOnDemand(false)
                   .HtmlAttributes(new { style = "display: inline-block;" })
                   .DataTextField("Text")
 
                   .Events(e =>
                       {
 
                           e.DragStart("menuDragStart");
                           e.DataBound("onDataBound");
                       })
                   .DragAndDrop(true)
                            .DataImageUrlField("ImageUrl")
                   .DataSource(ds => ds
                       .Model(m => m
                           .Id("Id")
                           .HasChildren("HasChildren")
                           .Children("Items")
                           )
                           .Events(e=>e.RequestEnd("requestEnd"))
 
                   .Read(r => r.Action("GetMenuTreeItems", "Menu")
 
                           )
                           )
                           .HtmlAttributes(new { style = "width:480px;height:600px;" })
 
                   )

Thanks

 

Ivan Danchev
Telerik team
 answered on 23 Aug 2016
3 answers
67 views
I have a grid that uses Batch mode.  On the Save event  I need to obtain a reference to a dropdownlist (not the cell, but the widget) in the 4th cell of this grid.  How do you do this?
Greg
Top achievements
Rank 1
 answered on 22 Aug 2016
2 answers
263 views

I have a map that a user will utilize in order to mark their position. I use geolocation and Bing layer to give them a good start. I want them to click on the map, have it recenter to the point they click, remove the existing marker, then create a new one where the map is centered.

 

function onClick(e) {
            var resultArray = e.location.toString().split(',');
            
            $('#map').data("kendoMap").center([parseFloat(resultArray[0]), parseFloat(resultArray[1])]);
            $('#map').data("kendoMap").markers.clear();
            $('#map').data("kendoMap").markers.add([parseFloat(resultArray[0]), parseFloat(resultArray[1])]);
        }

The function above centers the map, removes the previous marker, and does not give an error on the ADD.  However, the new marker doesn't show up.

Help please.

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 19 Aug 2016
1 answer
66 views

Hi,

 I have a grid with checkboxes in the last column.

I want the user to select the hours in the grid he wants to move.
After selecting all the hours he needs I want him to press a button and there should be an action against all selected lines.

 

See alse the attached screenshot.

 

How can I do this?

Eyup
Telerik team
 answered on 19 Aug 2016
7 answers
1.1K+ views

Hi,

ClientTemplate for the ID value is not working for me. Still outputs the ID to Service field. What am I missing?

Main .cshtml:

Main .cshtml:
@(Html.Kendo().Grid(Model.ManualJobItems)
      .Name("gridBreakDowns")
      .Columns(columns =>
      {
          columns.Bound(p => p.ItemID).Hidden(true);
          columns.Bound(p => p.ParentID).Hidden(true);
          columns.Bound(p => p.FileName).Title("File").Width(130);
          columns.Bound(p => p.ServiceName).Title("Service").Width(200).ClientTemplate("#=ServiceName#").EditorTemplateName("ServiceId");
          columns.Bound(p => p.Country).Title("Country").Width(300).EditorTemplateName("CountryId");
          columns.Bound(p => p.Format).Title("Format").Width(200);
          columns.Bound(p => p.Method).Title("Service Level").Width(200);
          columns.Bound(p => p.Quantity).Title("Quantity").Width(100);
          columns.Bound(p => p.ItemWeight).Title("Item Weight").Width(200);
          columns.Bound(p => p.TotalWeight).Title("Total Weight").Width(200);
          columns.Bound(p => p.DespatchStatusString).Title("Status");
          columns.Command(command => { command.Destroy(); }).Width(100);
      })
      //.Events(events => events.Edit("onGridEdit").Save("onGridSave"))
      .Editable(editable => editable
          .Mode(GridEditMode.InCell))
              .ToolBar(toolBar =>
              {
                  toolBar.Custom().Text("Create").Name("addNewRow").Url("#").HtmlAttributes(new {onclick = "addNewCustomRow()" });
                  toolBar.Save();
              })
            .Events(e => e.DataBound("onRowBound"))
            .DataSource(dataSource => dataSource
          .Ajax()
          .Batch(true)
          .Events(events => events.Error("onerror_handler"))
          .Create(create => create.Action("UpdateManualJobItem", "ManualJob"))
          .Read(read => read.Action("ReadManualJobItem", "ManualJob", new { jid = Model.JobID }))
          .Update(update => update.Action("UpdateManualJobItem", "ManualJob"))
          .Destroy(destroy => destroy.Action("DestroyManualJobItem", "ManualJob"))
          .Model(model =>
          {
              model.Id(p => p.ItemID);
          })
))
 
ServiceId.cshtml:
@(Html.Kendo().DropDownListFor(m => m)
    .OptionLabel("Select Service...")
    .DataTextField("ServiceName")
    .DataValueField("ServiceID")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetCurrentNormalServices", "System");
        });
        source.ServerFiltering(true);
    }))
     
CountryId.cshtml:
@(Html.Kendo().DropDownListFor(m => m)
    .OptionLabel("Select Country...")
    .DataTextField("CountryName")
    .DataValueField("CountryID")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetServiceCountries", "System").Data("filterCountries");
        });
        source.ServerFiltering(true);
    })
    .CascadeFrom("ServiceID"))
     
SystemController:
public JsonResult GetCurrentNormalServices()
{
    var services = _db.Services.GetAllCurrentNormalServices().Select(x => new { x.ServiceID, x.ServiceName }).ToList();
    return Json(services, JsonRequestBehavior.AllowGet);
}

neet-o
Top achievements
Rank 1
 answered on 19 Aug 2016
2 answers
160 views

I have a five digit postal code and want to exclude zero as first character and only allow numeric values.

Html.Kendo().MaskedTextBoxFor(a => a.Postnummer)
                    .Rules(rules => { rules.Add('0', "/[1-9]/"); })
                    .Mask("00000"))

 

not working, cant type in 0 at all.

Reine
Top achievements
Rank 1
 answered on 19 Aug 2016
1 answer
201 views

Hi there,

I want a chart similiar to the one attached with this thread. Currently I am using scatter chart for my purpose but it would be great if I could get it colored like the attached screenshot.

Any help would be greatly appreciated.

 

 

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 18 Aug 2016
17 answers
456 views

Hi guys is it possible to add upload control inside subgrid with clientdetailtemplate?because after adding the control the main grid it nolonger loads the data, please see below the code 

<div  style="clear:both;  position:relative; padding-top: 10px">
 
@(Html.Kendo().Grid<KendoUIApp1_Test.Models.IncidentsViewModel>()
              .Name("grid")
          
 
              .Columns(colums =>
              {
                   * http://www.telerik.com/blogs/kendo-ui-r1-2016-webinar-wrapup
                   */
                  colums.Bound(p => p.DepartmentID).Hidden(true);
                  colums.Bound(p => p.SiteAuditID).Hidden(true);
                  colums.Bound(p => p.QuestionID).Hidden(true);
 
                  colums.Bound(p => p.StatusName).Title("Status").Filterable(false).ClientTemplate(
                                                                                                   "# if (StatusID === 1 ) { #" +
                                                                                                     "<span class='CBdrawingstatusGreen'>#:StatusName#</span>" +
                                                                                                  "# } else if (StatusID === 2 ) { #" +
                                                                                                      "<span class='CBdrawingstatusYellow'>#:StatusName#</span>" +
                                                                                                  "# } else { #" +
                                                                                                      "<span class='CBdrawingstatusred'>#:StatusName#</span>" +
                                                                                                  "# } #"
 
                                                                                                );
                  colums.Bound(p => p.ReferenceNo).Title("ReferenceNo").Filterable(true);
                  colums.Bound(p => p.IncidentDate).Title("IncidentDate").ClientTemplate("#= kendo.format('{0:MM/dd/yyyy HH:mm:ss}',kendo.parseDate(IncidentDate)) #"); //.Filterable(model => model.UI("IncidentDateFilter"));
                  colums.Bound(p => p.AccountName).Title("Airport").Filterable(false).Width(200);
                  colums.Bound(p => p.SiteName).Title("Site").Filterable(false);
                  colums.Bound(p => p.Department1).Title("Department").Filterable(false);
                  colums.Bound(p => p.Description).Title("Description").Filterable(false);
                  colums.Bound(p => p.Comments).Title("Comments").Filterable(false);
                  colums.Bound(p => p.ContactName).Title("CurrentAssignedContact").Filterable(false).Width(200);
                  colums.Bound(p => p.FirstName).Title("CurrentAssignedUser").Filterable(false);
                  colums.Bound(p => p.IncidentID).ClientTemplate("<a class='k-button' href='" + Url.Action("GetPDF", "Home") + "?IncidentID=#= IncidentID #'" + "> <span span class='k-icon k-i-pdf''></span>Get Incident Pdf</a>").Title("Download PDF").Filterable(false);
                
                  colums.Command(cmd =>
                  {
                      cmd.Edit();
                      //cmd.Custom("Upload").Click("onCustomCommandClick");
                  });
 
              })
              .ClientDetailTemplateId("client-template")
          .Filterable(filterable => filterable
            .Extra(true)
            .Operators(operators => operators
                .ForString(str => str.Clear()
                    .StartsWith("Starts with")
                    .IsEqualTo("Is equal to")
                    .IsNotEqualTo("Is not equal to")
 
                ))
            )
 
    .HtmlAttributes(new { style = "height:550px;" })
    .DataSource(datasource => datasource
    .Ajax() //Configure the grid data source
     
    .Events(Eevents => Eevents.RequestEnd("OnChangeRefresh"))
    .Model(model =>
    {
        model.Id(m => m.IncidentID);
 
 
    })
    .Read(read =>
    {
        read.Action("GetIncidents", "Home").Data("IncidentsFilter");
    })// set the action method which will return the data in json format
 
    .Update(update => update.Action("Incidents_Update", "Home"))
    )
 
    .Navigatable()
    .Groupable()
    .Pageable()
    .Reorderable(reorder => reorder.Columns(true))
    .Sortable()
    .Scrollable()
        .Events(events =>
        {
            events.Save("onIncidentUserAssign");
            // events.Save("onStatusChange");
 
        })
 
            .Events(eEvents => eEvents.Edit("disableOnEdit"))
            .Events(x => x.DataBound("onDataBound"))
        //.Events(events =>
        //{
        //  events.Save("onStatusChange");
        //   // events.Save("onStatusChange");
 
        //})
 
 
    .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Incidents")
                                               .Window(w => w.Animation(true)
                                               .Scrollable(false)
                                               .Name("editWindow")))
     
 
        )
    
    </div>
 
<script id="client-template" type="text/x-kendo-template">
    @(Html.Kendo().Grid<KendoUIApp1_Test.Models.AuditPicIncidentModel>()
        .Name("Grid_#=SiteAuditID#")
          .ToolBar(toolbar => toolbar.Template(
     
        @<text>
            @(Html.Kendo().Upload()
                  .Name("files")
                  .Async(a => a.Save("Save", "Home"))
                  .Events(e => e.Success("onUploadSuccess"))
                  .ShowFileList(false) // Hide the file list as we're displaying uploaded files in the Grid
            )
          </text>
    ))
        .Columns(columns =>
                            {
                                columns.Bound(b => b.FileName).Title("File Name");
                                columns.Bound(b => b.PictureCaption).Title("Picture Caption").HtmlAttributes(new { style = "overflow: hidden;text-overflow: ellipsis;white-space:nowrap;" }).EditorTemplateName("ConfigurationSettingItemEditor");
                          
                                columns.Command(command => command.Destroy()).Width(100);
                                 
                            }
                )
        .Sortable()
        .Pageable(c => c.PageSizes(new int[] { 10, 20, 50, 100 }))
        .Scrollable()
        .HtmlAttributes(new { style = "height:430px;" })
        .DataSource(datasource => datasource
                    .Ajax()
                      .Model(model =>
                            {
                                model.Id(q => q.AuditResultPictureID);
                                //model.Field(q => q.KeyValue).Editable(true);
                                //model.Field(q => q.Enabled).DefaultValue(true);
  
                            })
                    .PageSize(10)
                    .ServerOperation(true)
                    .Read(read => read.Action("ConfigurationItem_Read", "Home", new { SiteAuditID = "#=SiteAuditID#", QuestionID = "#=QuestionID#" }))
                    .Destroy(update => update.Action("FilesDestriy", "Home"))
                     )
                      
                      
        .ToClientTemplate()
          
          
  
  
    )
 
   
  
</script>

Marc Plaxton-Harrison
Top achievements
Rank 1
 answered on 18 Aug 2016
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?