Telerik Forums
UI for ASP.NET MVC Forum
5 answers
179 views
Hi!

Is it possible to have a sparkline inside a listview HTML template?
If so, what is the best practice regardning binding it to data?

Regards,
Per
Iliana Dyankova
Telerik team
 answered on 18 Jun 2014
3 answers
81 views
Hello,

I have downloaded UI for ASP.NET MVC Q1 2014, and built a sample project
(unfortunately, i'm not able to attach project size more than 2MB)

On last page of the grid I get displace of headers and table contents:



Would be glad to receive your kind assistance

Shabtai
Dimo
Telerik team
 answered on 18 Jun 2014
1 answer
161 views
I have defined a DropDownListFor in my view as follows:
@(Html.Kendo().DropDownListFor(m=>m.BusinessUnitId)
 .OptionLabel("Select item...")
 .BindTo(new SelectList(Model.BusinessUnitList, "Key", "Value"))
)
where BusinessUnitList is a Dictionary<string, string> of value BusinessUnitIds and their descriptions.
Everything looks good on the screen and I can select a value and see its value via jQuery using: $("#BusinessUnitId").val()
However, when I try to submit the form, I get the following error:
System.ArgumentNullException
"Value cannot be null. Parameter name: items"
Alexander Popov
Telerik team
 answered on 18 Jun 2014
4 answers
680 views
I'm trying to get search results to display in a tooltip window.  I've got the tooltip working to pass my search text to my partial view, but it only works on the first call.  Every time the tooltip loads again, the results are the same, because the content is never reloaded.  Is there a way to not cache what comes back from the tooltips .LoadContentFrom function, so that I can pass new parameters back to the partial view each time?
Here is what I have for the tooltip.
What I'd like is that everytime the tooltip is show, the LoadContentFrom is called.
@(Html.Kendo().Tooltip()
    .For("#searchButton")   
    .LoadContentFrom("AllSearch", "Search", new { area = "" })   
    .ShowOn(TooltipShowOnEvent.Click)
    .Position(TooltipPosition.Bottom)
    .AutoHide(false)
    .Width(600)
    .Height(600)
    .Callout(true)
    .Animation(true)   
    .Events(e =>
        {
            e.RequestStart("requestStart");           
        })
)

<script>
    function requestStart(e) {
        var st = $("#searchText").val();
 
        e.options.data = {
            searchText: st
        }
    }
     
</script>
Rosen
Telerik team
 answered on 17 Jun 2014
4 answers
500 views
I have looked at similar postings but I am unable to figure it out. The json data is displaying as text, not through the view

CONTROLLER
[HttpPost]
        public JsonResult ReportsPhoneSupport([DataSourceRequest] DataSourceRequest request, ReportsPhoneSupport model)
        {
            string[] userIds = model.UserId.Split(',');
            ReportPhoneSupportResultTypedView results = new ReportPhoneSupportResultTypedView();
            foreach (string userId in userIds)
            {
                int iUserId = 0;
                if (Int32.TryParse(userId, out iUserId))
                {
                     
                    RetrievalProcedures.FetchReportPhoneSupportResultTypedView(results, model.FromDate, model.ToDate, iUserId);
                }
            }
            var Results = from Reslt in results
                          select new{
                              ActivityDate = Reslt.ActivityDate,
                              Action = Reslt.Action,
                              Assignment = Reslt.Assignment,
                              Description = Reslt.Description,
                              Result = Reslt.Result,
                              ToFrom = Reslt.ToFrom
                          };
            return Json(Results.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
             
        }
VIEW
@{
    ViewBag.Title = "ReportsPhoneSupport";
}
 
<h2>ReportsPhoneSupport</h2>
 
 
@(Html.Kendo().Grid<ZoomAudits.DAL.TypedViewClasses.ReportPhoneSupportResultRow>()
    .Name("grid")
     
    .Columns(columns =>
    {
        columns.Bound(m => m.ActivityDate).Format("{0:MM/dd/yyyy}").Title("Activity Date");
        columns.Bound(m => m.Assignment).Title("Assignment");
        columns.Bound(m => m.Action).Title("Action");
        columns.Bound(m => m.ToFrom).Title("ToFrom");
        columns.Bound(m => m.Result).Title("Result");
        columns.Bound(m => m.Description).Title("Description");
    })
     
    //.AutoBind(true)
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
     
    .DataSource(dataBinding => dataBinding
        .Ajax()
        .ServerOperation(false)
        .PageSize(20)
             
                .Read(read => read.Action("ReportsPhoneSupport", "ReportsPhoneSupport"))
     )
)
Example of displayed data 
{"Data":[{"ActivityDate":"\/Date(1398866129000)\/","Action":"Call Placed","Assignment":9538,"Description":"Spoke with insured, Krsto Djurovski (Chris),
Lee
Top achievements
Rank 1
 answered on 16 Jun 2014
1 answer
159 views
Hi,

We have a page with several combobox's and due to the delay from them all AutoBinding the page loads with the numeric value displaying inside the textbox and is only replaced by the text after the bind.  Is there a way to set an initial data binding while still attaching the read method to load server filtered alternatives via Ajax?  This way the page will display the text on load, and avoid multiple simultaneous ajax requests.

For example here is some failed code I've tried to give you some idea of what I would like.

@(Html.Kendo().ComboBoxFor(x => x.List[i].ID)
                            .DataTextField("Name")
                            .DataValueField("ID")
                            .Filter(FilterType.StartsWith)
                            .MinLength(3)
                            .BindTo(new List<ItemDTO>(){
                                new ItemDTO(){
                                    ID = Model.List[i].ID,
                                    Name = Model.List[i].Name
                                }
                            })
                            .AutoBind(false)
                            .DataSource(ds =>
                            {
                                ds.Read(r => r.Action("Action", "Controller").Data("filter")).ServerFiltering(true);
                            })
                            .Events(e => e.Change("Change"))
                    )

Thanks,
Kevin
Daniel
Telerik team
 answered on 16 Jun 2014
1 answer
107 views
When I generate a kendo control  thanks to Jquery, it is easy to select and put it in a javscript var  for doing stuffs on it
@section scripts
{
    <script>
        $(document).ready(function () {
 
              var slider = jQuery("#slider").kendoSlider({
                increaseButtonTitle: "Right",
                decreaseButtonTitle: "Left",
                showButtons: true,
                min: 1,
                max: 4,
                largeStep: 1,
                tooltip: {
                    enabled: false
                }
            });
 });
  </script>
}
 
<input id="slider" class="sliderClass" />
I would like to be able to select the same kendo control generated by the helper way, and put it  in javascript var but i can't manage to do it . Any ideas??????
@section scripts
{
    <script>
 
       var slider = $(".balSlider").kendoSlider; //want to select the kendo control and put it in a  var  but FAIL!!!
   </script>
}
 
 @(Html.Kendo().Slider()
                  .Name("titio")
                  .IncreaseButtonTitle("Right")
                  .DecreaseButtonTitle("Left")
                  .Min(0)
                  .Max(3)
                  .SmallStep(1)
                  .Value(0)
                           .Events(events => events
                      .Slide("sliderSlide")
                     )
                  .HtmlAttributes(new { @class = "balSlider" })
                ))
Sebastian
Telerik team
 answered on 16 Jun 2014
2 answers
121 views
Hello, 

I have been evaluating the grid and I cant seem to get the Create method to work , no reaction on the grid. The edit works fine, which is using the custom template. The grid is configured to work in the popup edit mode. 

Perhaps I am missing something small, but even the sample project that i downloaded from the code library (foreignkeydemo) doesnt work. 

I have followed the examples in the documentation to no avail. 

Here is the code below, i would appreciate if anyone can point me in the right direction or perhaps some documentation that i might have missed. 

Thanks in advance. 

Max. 

Index.cshtml. 

@using PMTrack   
 
    
<script type="text/kendo" id="memberTemplate">
        <ul>  
            #for(var i=0; i<data.length; i++){#
            <li> #:data[i].Firstname +" "+ data[i].Lastname #</li>
         #}#
          
        </ul> 
</script> 

<script type="text/javascript">
   var memberTemplate = kendo.template($("#memberTemplate").html(), {useWithBlock:false})
</script>

@(Html.Kendo().Grid<Project>()
      .Name("grid")
      .Columns(columns =>
          {
              columns.Bound(p => p.Id).Width(5).Title("#").Filterable(false);
              columns.Bound(p => p.Name).Width(60).Title("Project name");
              columns.Bound(p => p.StartDate).Width(50).Filterable(true).Format("{0:dd/MM/yyyy}");
              columns.Bound(p => p.PlannedEndDate).Width(50).Format("{0:dd/MM/yyyy}");
              columns.Bound(p => p.Status).Width(20);
              columns.Bound(p => p.Members).ClientTemplate("#=memberTemplate(Members)#").Width(100);
              columns.Bound(p => p.Owner.Firstname).ClientTemplate("#=Owner?Owner.Firstname:''#").Title("Owner").Width(50);
              columns.Command(command =>
                  {
                      command.Edit();
                      command.Destroy();
                      

                  }).Width(40); 
                                                                                                                                                          
          } )
      .ToolBar(toolbar =>  toolbar.Create().Text("New Project"))
      .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ProjectEditorTemplate"))
      .Pageable()
      .Sortable()
      .HtmlAttributes( new { style="width:900px"})
      .Filterable()
      .DataSource(ds => ds.Ajax().Events(e => e.Error("onError"))
                          .PageSize(20)
                          .Model(model => model.Id(p =>p.Id))
                          .Read(read => read.Action("Read", "Home"))
                          .Update(update=> update.Action("Update", "Home"))
                          .Destroy(destroy => destroy.Action("Delete", "Home"))
                          .Create(create => create.Action("Insert", "Home").Type(HttpVerbs.Post))
      ))
  
<script type="text/javascript">
    function onError(e) {
        if (e.errors) {
            var message = "Errors:\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            alert(message);
        }
    }
</script>



<script>
    $(document).ready(function () {
        kendo.culture("en-GB");

    });
</script>


The Controller : 
public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        {

            var ps = new ProjectService();


            return Json(ps.Read().ToDataSourceResult(request));

        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, Project project)
        {
            if (project != null && ModelState.IsValid)
            {
                var ps = new ProjectService();
                ps.Update(project);

            }
            return Json(new[] { project }.ToDataSourceResult(request, ModelState));
        }

        public ActionResult Delete([DataSourceRequest] DataSourceRequest request, Project project)
        {
            if (project != null)
            {
                var ps = new ProjectService();
                ps.Delete(project);
            }

            return Json(new[] { project }.ToDataSourceResult(request, ModelState));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Insert([DataSourceRequest] DataSourceRequest request, Project project)
        {


            if (project != null && ModelState.IsValid)
            {
                var ps = new ProjectService();
                ps.Create(project);
            }


            return Json(new[] { project }.ToDataSourceResult(request, ModelState));
        }


        public ActionResult Index()
        {
            var ms = new MemberService();

            var members = ms.GetAll();

            var status = new List<string>
                {
                    "Development",
                    "Validation"
                };


            ViewData["status"] = status;

            ViewData["owners"] = members;

            ViewData["members"] = members;

            return View();
        }








Max
Top achievements
Rank 1
 answered on 16 Jun 2014
1 answer
614 views
I'm using the UI for MVC MaskedTextBoxFor construct with phone numbers.  

For basic areacode+number, it's working fine.   But I don't see anything in the documentation about how to add an additional optional extension number to the end - for a maximum form of "(000) 000-0000 x09999".   In your documentation I saw no predefined mask rules for optional parts of the mask.

I see that I can do the validation part of this with a regex rule but don't see how to get the mask to automatically insert the " x" after the end of the "3333" part of the number in preparation of an option 1 to 5 number extension if and only if the user continues typing characters after typing the primary number "(000) 000-0000" part.

I'm assuming that this should be able to be be done via a custom mask rule function, but didn't see any examples in your documentation involving optional pieces of content where fixed content like the " x" will be auto-added for the user.

Thanks!
-Bob
Georgi Krustev
Telerik team
 answered on 16 Jun 2014
3 answers
346 views
I've been using the Grid successfully to implement paging, sorting, filtering via server-side POSTs, it all works great. However, I am having trouble getting the DELETE buttons (and possibly UPDATE as well) to immediately post, it seems like the control is waiting/batching them up... and I don't want that behavior. I want immediate POSTs for delete and update.

Can anyone see where I'm going wrong here?

Thanks,
Craig


<script type="text/javascript">
    $(function () {
        $("#employeesGrid").kendoGrid({
            toolbar: ["create", "save", "cancel"],
            columns: [
                { field: "FirstName", title: "First Name" },
                { field: "LastName", title: "Last Name" },
                { command: "destroy" }
            ],
            dataSource: new kendo.data.DataSource({
                transport: {
                    read: {
                        url: "api/Customer",
                        type: "POST",
                        contentType: "application/json"
                    },
                    destroy: {
                        url: "api/Customer/Delete",
                        type: "POST"
                        //contentType: "application/json"
                    },
                    parameterMap: function (options, operation) {
                        if (operation === "read")
                            return kendo.stringify(options);
                        else
                            return options;
                    }
                },
                schema: { data: "Data", total: "Count", model: { id: "Id"} },
                pageSize: 5,
                serverPaging: true,
                serverSorting: true,
                error: function (e) {
                    console.log(e.statusText);
                }
            }),
            batch: false,
            editable: {
                //mode: "popup",
                destroy: true
            },
            scrollable: false,
            sortable: true,
            pageable: true
        });
    });
</script>
Petur Subev
Telerik team
 answered on 16 Jun 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?