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

I have a grid with data on it. When I want to edit the data, I need to press the edit button and a new edit form will open with the current data from the row.

For the textboxes I use: 

@Html.EditorFor(model => model.SubStatus)

Now the issue is the dropDownList. Here is my code. the initial value is always blank?

CSHTML code:

@(Html.Kendo().DropDownListFor(m => m.SubType)
                .Name("SubsType") 
                .DataTextField("SubType1")
                .DataValueField("SubType_ID") 
                .DataSource(source =>
                {
                    source.Custom()
                          .ServerFiltering(true)
                          .Type("aspnetmvc-ajax")
                          .Transport(transport =>
                          {
                              transport.Read("GetType", "Welcome");
                          })
                          .Schema(schema =>
                          {
                              schema.Data("Data")
                                    .Total("Total"); 
                          });
                })
            )

 

Razor code:

 public JsonResult GetSubType([DataSourceRequest] DataSourceRequest dropDownRequest)
        {
            IList<SubType> myViewModels = new List<SubType>();

            foreach (SubType subType in db.ExecuteStoredProcedure<SubType>("proc_getType", null))
            {
                SubType subtype = new SubType()
                {
                    SubType_ID = subType.SubType_ID,
                    SubType1 = subType.SubType1
                };
                myViewModels.Add(subtype);
            }
            return Json(myViewModels.ToDataSourceResult(dropDownRequest), JsonRequestBehavior.AllowGet);
        }

Right now I get the list from the database. when the dropdownlist is pressed. but I want to set the initial value of the list to be the current value. How to do it?

Georgi Krustev
Telerik team
 answered on 14 May 2015
1 answer
244 views

From an example in another thread, I was able to enable dragging from a grid onto a TreeView control.

However, the example just fired an alert with the ID of the object that was dragged. What I need to do is insert the dragged row into the TreeView . I can use the append method to add to the TreeView , but can't work out how to identify the node that the grid record was dragged onto.

 

My current client code is:-

<div class="pull-left" style="margin-right:20px;">
 
    @(Html.Kendo().TreeView()
                    .Name("Treeview")
                    .ExpandAll(true)
                    .HtmlAttributes(new { style = "display: inline-block;" })
                    .DataTextField("Text")
 
                    .DataSource(ds=>ds
                        .Model(m=>m
                            .Id("Id")
                            .HasChildren("HasChildren")
                            .Children("Items")
                             
                            )
                        
                    .Read(r => r.Action("GetMenuTreeItems", "Menu")
                              
                            )
                            )
    )
 
</div>
 
<div class="pull-left" style="width:500px;">
    @(Html.Kendo().Grid<BI_II.Models.SSRS_Report>()
.Name("Grid")
.Columns(col =>
    {
        col.Bound(o => o.Name).Title("Name");
        //col.Bound(o => o.ItemID).Title("ItemID");
    })
 
  .DataSource(ds => ds
    .Ajax()
    .Model(m => m.Id(p => p.ItemID))
    .PageSize(15)
        .Read(rd => rd.Action("RD_ReportList", "Menu")
    )
)
.Pageable()
.Sortable()
.Filterable()
 
    )
</div>
<script>
 
    $(document).ready(function () {
 
        var grid = $("#Grid").data("kendoGrid"),
             treeview = $("#Treeview").data("kendoTreeView"),
            itemUID;
 
        grid.table.kendoDraggable({
            cursorOffset: {
                top: 5,
                left: 5
            },
            filter: "tbody > tr",
            group: "Grid",
            hint: function (e) {
                itemUID = e.attr(kendo.attr("uid"));
                return $('<div class="k-grid k-widget"><table><tbody><tr>' + e.html() + '</tr></tbody></table></div>');
            }
        });
         
        treeview.element.kendoDropTarget({
            group: "Grid",
            drop: function (e) {
 
                var model = grid.dataSource.getByUid(itemUID);
 
                 treeview.append({ Text: model.Name, Id: model.ItemID });
 
       
 
                itemUID = null;
            }
        });
 
    });
</script>

 This currently just appends into the TreeView root node.

 Thanks

Daniel
Telerik team
 answered on 14 May 2015
2 answers
189 views

Is it possible to add a kendo context menu to a TreeView node?  I can't seem to find any examples or posts about this.

 

Thanks

AP
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 14 May 2015
8 answers
251 views
i'm migrated my project to Kendo UI v2014.3.1316 (previously kendo v2014.2.1008) and the mobile popover widget doesn't instantiate anymore. With previous version it work fine..
My sample code:< div id="popUser" kendo-mobile-pop-over="popUser" k-popup='{}'>
< /div >error:
TypeError: Cannot read property 'element' of undefined
at new D.extend.init (http://localhost:25586/Scripts/kendo/kendo.all.min.js:27:19741)
at new a.extend.init (http://localhost:25586/Scripts/kendo/kendo.all.min.js:27:25449)
at new u.extend.init (http://localhost:25586/Scripts/kendo/kendo.all.min.js:27:31527)
at HTMLDivElement. (http://localhost:25586/Scripts/kendo/kendo.all.min.js:10:2045)
at Function.jQuery.extend.each (http://localhost:25586/Scripts/jquery/jquery-1.11.1.js:383:23)
at jQuery.fn.jQuery.each (http://localhost:25586/Scripts/jquery/jquery-1.11.1.js:136:17)
at mt.plugin.e.fn.(anonymous function) as kendoMobilePopOver
at m (http://localhost:25586/Scripts/kendo/kendo.angular.min.js:9:1274)
at o (http://localhost:25586/Scripts/kendo/kendo.angular.min.js:9:1737)
at w.directive.directive.directive.directive.directive.directive.directive.directive.directive.link.pre (http://localhost:25586/Scripts/kendo/kendo.angular.min.js:9:13712)error screenshot from chrome:
http://i60.tinypic.com/2vtozf6.pngany suggestion?
thanks
Petyo
Telerik team
 answered on 14 May 2015
0 answers
149 views
I am using Method 2 for binding my data to a flat file as shown here:
Binding to flat data
<div id="tree"></div>
<script>
var flatData = [
  { id: 1, parent: null, text: "Item 1" },
  { id: 2, parent: null, text: "Item 2" },
  { id: 3, parent: null, text: "Item 3" },
  { id: 4, parent: null, text: "Item 4" },
  { id: 5, parent: 1, text: "Item 1.1" },
  { id: 6, parent: 1, text: "Item 1.2" },
  { id: 7, parent: 1, text: "Item 1.3" },
  { id: 8, parent: 3, text: "Item 3.1" },
  { id: 9, parent: 3, text: "Item 3.2" },
  { id: 10, parent: 5, text: "Item 1.1.1" },
  { id: 11, parent: 5, text: "Item 1.1.2" },
  { id: 12, parent: 5, text: "Item 1.1.3" }
];
 
// tree for visualizing data
$("#tree").kendoTreeView({
  dataSource: {
    transport: {
      read: function(options) {
        var id = options.data.id || null;
 
        options.success($.grep(flatData, function(x) {
          return x.parent == id;
        }));
      }
    },
    schema: {
      model: {
        id: "id",
        hasChildren: function(x) {
          var id = x.id;
 
          for (var i = 0; i < flatData.length; i++) {
            if (flatData[i].parent == id) {
              return true;
            }
          }
          return false;
        }
      }
    }
  }
})
</script>
Now, however, I need to add some icons to differentiate the kind of file (Folder, excel, PDF, etc)
I have found a series of icons that I think would work would work at:
jQuery icons styling example
I just am not sure how to add the desired icons (or their references) into the JSON or set the TreeView up to show them.
All of the examples that I have found show both the data and the icon hard coded and I need to know how to have the icons in the JSON and for the tree to then generate them.
I have tried adding a JSON field called "image" and at a different time one called "icon" - neither seemed to work.
So, how would I set the icons up and show them?

TIA,
Bob Mathis
Bob
Top achievements
Rank 2
 asked on 13 May 2015
2 answers
1.0K+ views

Hi guys,

I've setup a datepicker, it's showing the selected date properly but I'm having a hard time in sending it towards my controller in the same format it's showing. For some reason it seems to be reverting back from dd/MM/yyyy to MM/dd/yyyy.

Below my script used.

01.<script>
02.    var datepicker;
03.    $(document).ready(function () {
04.        datepicker = $("#datepicker").data("kendoDatePicker");
05. 
06.        $("#btnToReport").click(function () {
07.            $.post("/ShiftReport/ViewReport?datepicker=" + datepicker.value().toLocaleString(), function (data, status) {
08.                if (status === "success") {
09.                    $("#main-content").html(data);
10. 
11.                }
12.            });
13.        });
14.    });
15.</script>

Daniel
Telerik team
 answered on 13 May 2015
4 answers
101 views

Hi all,

we are implementing a grid using asp.net mvc and aspx pages. We are encountering a couple of problems using templates because it seems

that Visual Studio 2013 does not recognize the object implementation correctly. The error returned by Visual Studio is the CS1525:Invalid expression term ')'..  This is our code with the comments..

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SiteEnvironment.Master" Inherits="System.Web.Mvc.ViewPage<MyApp.Models.EnvTblModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Environment List</h2>
<%:
Html.Kendo().Grid<MyApp.Models.EnvTblModel>()
    .Name("Grid")
    .BindTo((IEnumerable<MyApp.Models.EnvTblModel>)ViewBag.EnvironmentList)
    .Columns(colList =>
        {

            foreach (var runCol in ViewBag.colSchLst)
            {  

colList.Bound(runCol.TBS_BOUND_FIELD_NAME).Title(runCol.TBS_COLUMN_NAME);
            }
            colList.Bound(p =>
p.TBG_FILLER_CHK01).Template(p =>
            {       /*VISUAL STUDIO GIVES THE ERROR CS1525: Invalid expression term ')' HERE .. */
                %>
                    <strong><%: p.TBG_FILLER_CHK01 %></strong>   //THIS BLOCK SEEMS NOT RECOGNIZED 
                <%
            });
        });
%>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>

 

Thank you in advance for your help..

 

Regards

 

 

 

Rosen
Telerik team
 answered on 13 May 2015
1 answer
125 views
<div>
        @using (Html.BeginForm("SignIn", "Account",  FormMethod.Post,  new { @class = "form-horizontal", role = "form", autocomplete="off" }))
        {
            @Html.AntiForgeryToken()
            <dl class="dl-horizontal">
                <dt>
                    @Html.LabelFor(x => x.UserName)
                </dt>
                <dd>
                    @Html.TextBoxFor(x => x.UserName, new {@id="user_name", @disabled="true"})
                </dd>
                <dt>
                    @Html.LabelFor(x => x.Password)
                </dt>
                <dd>
                    @Html.PasswordFor(x => x.Password, new {@id="password", @autocomplete="off" , @disabled="true"})
                </dd>
                <dt>
                    @Html.LabelFor(x => x.StoreNum)
                </dt>
                <dd>
                    @(Html.Kendo().DropDownListFor(x => x.StoreNum)
                    .DataSource(ds => ds
                    .Read(r=> r.Action("GetStoreList", "Account")))
                    .HtmlAttributes(new {@id="store_list",@disabled="true" })
                    )
                </dd>
                <dd>
                    <input type="submit" value="Log in" class="btn btn-default" disabled="true" id="login_button" />
                </dd>
            </dl>
           
        }
    </div>

 

I have a drop down list that reads data from my controller.  I need to enable fields and a button in the UI after the data is loaded into the dropdownlist.  How can I do this?

Kiril Nikolov
Telerik team
 answered on 13 May 2015
1 answer
125 views

Hello,

I would like to catch the grid request i.e. when sorting or grouping via server and execute on some modal dialog when OK clicked. As I understand on requestStart we can perform some actions, but further execution flow will proceed. In my case I would like to display login dialog + some other login selections and if login succeeds, continue with the request. Is it possible?

Thanks

Daniel
Telerik team
 answered on 13 May 2015
5 answers
337 views
Hi,

I have a problem with decimal separators when doing inline editing.
Right now I have a solution that works, but I need more than two digits after the decimal separator:

The model:
[DataType("number")]
public double Percent
{
    get { return (double)Math.Round(source.Percent, 5); }
    set { source.Percent = (decimal)value; }
}

The view:
.Columns(columns =>
{
    columns.Bound(c => c.Percent).Title(Resource.Percent).Format("{0:n5}");

Setting the culture:
var c = '@System.Globalization.CultureInfo.CurrentCulture.ToString()'
kendo.culture(c);

The DataType=number, in the model, formats the inline input box the correct way.
The "Format("{0:n5}")", in the view, formats the number correctly in the grid.
There is no problems when updating the model (model-state is valid), but I need higher precision.

thanks.
Rosen
Telerik team
 answered on 13 May 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?