Telerik Forums
UI for ASP.NET MVC Forum
1 answer
217 views
I'm biding a treeview to a remote data and at this point the data is displayed correctly. The problem: when I change the data in the database and refresh my page, the treeview doesn't reflect the new data. It seems that the treeview is not calling the json action anymore after the first load.

I tried to work with LoadOnDemand and several other methods, but nothing worked so far. I need to refresh the data because when users drag and drop the nodes, the treeview will be updated in the database.

** Code is attached. I also just noticed that it works on Chrome but not IE 10. Thank you for any help.

I'm following this demo code: http://demos.kendoui.com/web/treeview/remote-data.html

This is my json action:

public JsonResult Categories(int? id)
{

var categories = from e in db.Categories
where (id.HasValue ? e.ParentCategoryID == id : e.ParentCategoryID == 1)
orderby(e.OrderNumber)
select new
{
id = e.CategoryID,
Name = e.CategoryNames.FirstOrDefault().Name,
ParentId = e.ParentCategoryID,
hasChildren = db.Categories.Where(j => j.ParentCategoryID == e.CategoryID).Any()
}
;

return Json(categories, JsonRequestBehavior.AllowGet);
}

This is my treeview code:

Html.Kendo().TreeView()
.Name("treeviewcategories")
.DataTextField("Name")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("Categories", "Settings")
)
)
.Events(events => events
.Select("onSelect")
.DragEnd("onDragEnd")
.Expand("onExpand")
)
.DragAndDrop(true) 
Development Team
Top achievements
Rank 1
 answered on 19 Aug 2013
2 answers
435 views
I have a grid that I can select a row on and then click a button on the grid to move that row's data item to a different grid.

This code has been working fine for months, but broke after the last official release.  I upgraded to the most up to date internal release today (2013.2.814), but still no luck.

Basically, anytime I run code like this:

var grid = $("#ItemBook").data("kendoGrid");
console.log(grid.select()); //Errors
I get a strange error in Firebug and no code after the select line executes.  The error looks a bit like this:
TypeError: r is undefined
...table)),t.css(kt?"padding-left":"padding-right",l.virtual?c+1:c),n=e('<tabl
However, searching for the row by the selected class DOES work.  E.g.:
console.log($("#SavedQuoteBook tr.k-state-selected"));  //Gives tr element
console.log(grid.dataItem($("#SavedQuoteBook tr.k-state-selected")));  //Give dataItem

I don't think it should matter, but the grid as well as the script executing the code above are inside a partial view that's loaded into a Menu Widget.

Here's the code for the views:

Menu Widget Declaration:
@(Html.Kendo().Menu()
                .Name("ItemMenu")
                .OpenOnClick(true)
                .CloseOnClick(false)
                .Items(items =>
                {
                    items.Add()
                        .Text("Items")
                        .Content(Html.Partial("ItemBook", Model.Items).ToHtmlString());
                })
                .Events(events =>
                {
                    events.Open("ItemMenuOpen");
                })
            )

Partial View (Grid + Script):
<script type="text/javascript">
    function ConfigureItemBook() {
   
        //Drives multi-selection of grid rows (Overrides native functionality)
        $("#ItemBook").delegate('tbody tr', 'click', function () {
            $(this).toggleClass('k-state-selected');
        });
 
        //Drive single selection by double click
        $("#ItemBook").delegate('tbody tr', 'dblclick', function () {
            $(this).addClass('k-state-selected');
            PopulateItem();
        });
    }
 
    function PopulateItem() {
        var grid = $("#ItemBook").data("kendoGrid");
 
        console.log("Manual Search");
        console.log($("#ItemBook tr.k-state-selected"));  //This works
        console.log("Manual Search + Get DataItem");
        console.log(grid.dataItem($("#ItemBook tr.k-state-selected")));  //This works
        console.log("Kendo Grid Select");
        console.log(grid.select());  //ERROR
        console.log("Kendo Grid Select + GetDataItem");
        console.log(grid.dataItem(grid.select()));  //ERROR
    }
</script>
 
@(Html.Kendo().Grid(Model)
    .Name("ItemBook")
    .TableHtmlAttributes(new { @style = "cursor:pointer;" })
    .Columns(columns =>
    {
        columns.Bound(i => i.DateCreated).Width(90);
        //Other columns omitted for brevity
    })
    .ToolBar(toolbar =>
    {
        toolbar.Custom().Text("Select").Url("#_").HtmlAttributes(new { onclick = "PopulateItem()" });
    })
    .Events(events =>
    {
        events.DataBound("ConfigureItemBook");
    })
    .Pageable()
    .Sortable()
    .Scrollable()
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    .DataSource(dataSource => dataSource
        .Ajax()
        .ServerOperation(false)
        .Model(model =>
        {
            model.Id(i => i.ID);
        })
    )
)


Jark Monster
Top achievements
Rank 1
 answered on 19 Aug 2013
2 answers
151 views
In out MVC app, we are using a Kendo grid to display/inline edit Department information. We also display a tree view of the Department hierarchy (see below). In Chrome when changes are made to the Department information the tree view dynamically changes, in IE10 this does not occur. We noticed through debugging that in IE10 the "GetDepartmentTree' action is only fired on initial load and is never called again, even when the department page is refreshed. In Chrome this action is fired with each change to the Department information. Any ideas on what we can do to make this more cross-browser compliant?

            @(Html.Kendo().TreeView()
                .Name ("DepartmentTree")               
                .HtmlAttributes(new {@class="dept-treeview"})
                .DataTextField("Name")
                .DataSource(ds => ds
                    .Read(read => read
                        .Action("GetDepartmetsTree", "Administration")
                        .Data("GetParameters")
                    )
                )               
                .LoadOnDemand(false)
            )

Dev Team
Top achievements
Rank 1
 answered on 19 Aug 2013
0 answers
90 views
I have a ASP.NET WebAPI endpoint that is receiving the calls for upload and it appears to be working fine in that the file is uploaded and it returns appropriate JSON.  It is however secured using windows authentication which seems to be causing a problem with loading the thumbnails.  What seems to be happening is that the initial call to the upload endpoint returns a 401 which causes the client to resend the request with the authorization cookie.  It seems that in between those two calls the tiles get updated and an img for the thumb is created even though the thumb hasn't been created on the server yet.  This causes the thumb not to load and it won't even try to load again until the browser is refreshed.  

Without security everything seems to go fine unfortunately the windows auth is a requirement of this application.  Is there a way to force the initial request to
include the auth token or is there a way to delay the reloading of the tiles/images until the second call is complete?  Seems to be mostly working great other than this issue.

Thanks,
Uriah
Uriah
Top achievements
Rank 1
 asked on 18 Aug 2013
5 answers
1.1K+ views
Is it possible to filter a column from a drop down list (from a foreign key look up table) - and if so what's the best way to do this?

The only way I can see to do this a present, is using a toolbar template - which isn't ideal but would be ok, but the example isn't for the MVC extensions ( http://demos.kendoui.com/web/grid/toolbar-template.html ), and it seems there should be an easier way in MVC.

Any examples would be helpful.

Thanks
Daniel
Top achievements
Rank 1
 answered on 16 Aug 2013
1 answer
151 views
<div class="k-block">
    <div class="k-header k-shadow"><span class="k-icon k-i-pencil"></span>Employee Colour</div>
    <div class="editor-label">
            @Html.LabelFor(x => x.BackgroundColour)
        </div>
        <div class="editor-field">
            @(Html.Kendo().ColorPicker().Name("BackgroundColour").Palette(ColorPickerPalette.Basic).Value(Model.BackgroundColour))
            @Html.TextBoxFor(x => x.BackgroundColourInput, new { @class = "editor-colour"})
        </div>
        <br />
        <div class="editor-label">
            @Html.LabelFor(x => x.TextColour)
        </div>
    <div class="editor-field">
        @(Html.Kendo().ColorPicker().Name("TextColour").Palette(ColorPickerPalette.Basic).Value(Model.TextColour))
         @Html.TextBoxFor(x => x.TextColourInput, new { @class = "editor-colour"})
    </div>
    <br/>
</div>
I'm using the code above to load a colour picker, the Model.BackgroundColour and Model.TextColour are strings as below:

rgb(0,255,255)

but when the form loads, the initial colour is always black, can someone tell me what I'm doing wrong please, as looking at the documentation it seems this should work. I should also point out that passing a string as below:

#00FFFF

does work.

Thanks.
Dimiter Madjarov
Telerik team
 answered on 16 Aug 2013
3 answers
173 views
Hello,
i am using Vs2012,kendo 2013.1.154 version,
and i want it to do the dropdown cascade example,and it gives me in firebug,that he doesn't know that javascript function put as filter
the error message is : filterProducts is not defined
here is my view
<div class="demo-section">
    <h2>View Order Details</h2>
    <p>
        <label for="categories">Catergories:</label>
        @(Html.Kendo().DropDownList()
              .Name("groups")
              .HtmlAttributes(new { style = "width:300px" })
              .OptionLabel("Select group...")
              .DataTextField("Name")
              .DataValueField("pkTallyGroup")
              .DataSource(source => {
                   source.Read(read => {
                       read.Action("GetCascadeGroups", "Employees");
                   });
              })
        )
    </p>
    <p>
        <label for="subgroups">Products:</label>
        @(Html.Kendo().DropDownList()
              .Name("subgroups")
              .HtmlAttributes(new { style = "width:300px" })
              .OptionLabel("Select subgroup...")
              .DataTextField("Name")
              .DataValueField("pkTallySubGroup")
              .DataSource(source => {
                  source.Read(read =>
                  {
                      read.Action("GetCascadeSubgroups", "Employees")
                          .Data("filterProducts");
                  })
                  .ServerFiltering(true);
              })
              .Enable(false)
              .AutoBind(false)
              .CascadeFrom("groups")
        )
        <script>
            function filterProducts() {
                return {
                    groups: $("#groups").val()
                };
            }
        </script>
    </p>
    
</div>

what should be the problem?or do i need to set something in VS2012 to see the scripts in the same page?
Regards,
Daniel
Vladimir Iliev
Telerik team
 answered on 16 Aug 2013
6 answers
135 views
Hello,
i have another question:
I would like to filter the grid data,based on some filters(textboxes or dropdowns) and when i press a button,the date will be loaded into the kendo grid.But initially i do not want to fill anything.based on filter inputs,i create the criteria and make the selection in where clause of the repository for the given entity.
How can i do that?can you show me an example?
Best Regards,
Daniel
Nikolay Rusev
Telerik team
 answered on 16 Aug 2013
0 answers
150 views
Hi to all Members.I have installed Kendo and i am using a very basic Grid
I have bind it successfully but paging sorting doesn't seems to Work

This is my View
@model IEnumerable<UserManagementApplication.Models.tblUser>
@{
    ViewBag.Title = "GetDataKendo";
}
<h2>GetDataKendo</h2>
   
@(Html.Kendo().Grid(Model)  
    .Name("Grid")
     .Columns(columns =>
      {        
          
          columns.Bound(model => model.FirstName);
          columns.Bound(model => model.LastName);
          columns.Bound(model => model.EmailAddress);
          columns.Bound(model => model.IsActive);
      })
      
    .Pageable()
    .Sortable()
    .Filterable()
    .Scrollable()
    .Groupable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("GetUserDataKendo", "User")
        )
    )
)

And this is my Controller Method
 public ActionResult GetUserDataKendo([DataSourceRequest]DataSourceRequest request)
        {                   
            
            var displayedEvents = client.GetUserList(1, 100, "", false, "");      
           var result = new DataSourceResult()
            {
                Data = displayedEvents
            };
            return Json(result);
        }


My problem is that Paging Sorting are not working .Please see attached Image that how my image is showing

Jack
Top achievements
Rank 1
 asked on 16 Aug 2013
2 answers
2.3K+ views

I have created a single page application with Kendo Grid.  and users have different roles. I need to Hide and show buttons on  User Role Type.
Chrys
Top achievements
Rank 1
 answered on 15 Aug 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
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
Iron
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?