Telerik Forums
UI for ASP.NET MVC Forum
3 answers
290 views
Hi,

I have two kendo grids which needs to be placed side by side (Both the grids uses same controller method).

My requirements.

1. Have to load >50000 rows(shouldn't take much time to load).
2. Scrolling should be in sync.
3. Paging should not be applied.
4. Column width should be auto.
5. Row height should be same for both the grids so that scrolling make sense.

Please share a demo on this.
Dimo
Telerik team
 answered on 17 Jun 2013
8 answers
1.0K+ views
I'm creating a Kendo.Mvc.UI.Menu in a Html Helper.  If the current controller/action matches the menu item then i set Selected to true. However, when the menu gets rendered to the page the current menu item is not selected.  Is there an init or onload event that is ignoring or overriding the Selected property?  It seems to only effect the current controller/action, if i set other menu items to Selected = true, they will stay selected.

Kendo.Mvc.UI.Menu menu = Kendo.Mvc.UI.HtmlHelperExtension.Kendo(helper).Menu();
menu.Name = "MainMenu";
  
IList<MenuItem> items = new List<MenuItem>();
  
items.Add(new MenuItem { Text = "Dashboard", Action = "Index", Controller = "Dashboard" });
items.Add(new MenuItem { Text = "Certificates", Action = "Index", Controller = "Certificates" });
  
UrlHelper Url = new UrlHelper(helper.ViewContext.RequestContext);
string controller = helper.ViewContext.RouteData.GetRequiredString("controller");
  
foreach (MenuItem item in items)
{
      menu.Items.Add(new Kendo.Mvc.UI.MenuItem { Url = Url.Action(item.Action,item.Controller),Text = item.Text, Selected = (item.Controller == controller)});
}
  
return new MvcHtmlString(menu.ToHtmlString());

Sorry, still transitioning from Telerik.Mvc...

Thanks,
Chris
Kendo MVC Version: v4.0.30319
Eric
Top achievements
Rank 1
 answered on 16 Jun 2013
4 answers
504 views
I can't seem to get remote validation to work in my popup edit window.  Normal validation ([Required] etc) seems to work fine, but the remote call to the JsonResult method isn't working.  In a plain MVC view for the same model the remote validator works as expected.

Here is the grid (most irrelevant columns removed)
@(Html.Kendo().Grid<UserModel>()
      .Name("Users")
      .ToolBar(commands => { commands.Create().Text("Create new User"); })
      .Columns(columns =>
      {
          columns.Bound(o => o.uidIdentity).Hidden();
          columns.Bound(o => o.UserName).Title("Users Name").Sortable(true).Filterable(true).Width(200)
              .HeaderHtmlAttributes(new { style = "text-align:center;align=center" }).HtmlAttributes(new { style = "text-align:center;align=center" });
          columns.Bound(o => o.Email).Title("Email Address ").Sortable(true).Filterable(true).Width(175)
              .HeaderHtmlAttributes(new { style = "text-align:center;align=center" }).HtmlAttributes(new { style = "text-align:center;align=center" });
 
      })
      .Events(events => events.DataBound("UserGrid_DataBound").Edit("UserGrid_edit"))
      .ClientDetailTemplateId("roleTemplate")
      .Sortable()
      .Editable(editing =>
          editing.Mode(GridEditMode.PopUp).Window(w => w.HtmlAttributes(new { })))
      .DataSource(dataSource => dataSource
        .Ajax()
        .Events(e => e.Error("error_handler"))
        .Read("_GetTpaUser", "User")
        .Create("_InsertUser", "User")
        .Update("_EditUser", "User")
        .Destroy("_DeleteUser", "User")
        .Model(model => model.Id(o => o.UserName))
        )
      .Filterable()
      .Scrollable(scroll => scroll.Enabled(true).Height(500))
      .Resizable(resize => resize.Columns(true))
      .Pageable(pager => pager.PageSizes(true))
)

Here is the controller JsonResult:

public JsonResult UserNameExists(string UserName)
{
    AccountRepository _repository = new AccountRepository();
    if (!(_repository.CheckUserNameExists(UserName)))
        return Json(true, JsonRequestBehavior.AllowGet);
    else
        return Json(string.Format("User name: {0} is already in use.", UserName), JsonRequestBehavior.AllowGet);
 
}

Here is the model (irrelevant fields removed):

public class UserModel
    {
        #region Constructor
        public UserModel()
        {
            
        }
        #endregion
        private AccountRepository _reposAcct = new AccountRepository();
        private spGetUserProfileResult _UserProfile = new spGetUserProfileResult();
 
        public Guid UserGuiD { get; set; }
        public int UserID { get; set; }
        [Required(ErrorMessage = "First Name Required")]
        [DisplayName("First Name:")]
        public string FirstName
        {
            get
            {
                return _UserProfile.FirstName;
            }
            set
            {
                _UserProfile.FirstName = value;
            }
        }
        [Required(ErrorMessage = "Last Name Required")]
        [DisplayName("Last Name:")]
        public string LastName
        {
            get
            {
                return _UserProfile.LastName;
            }
            set
            {
                _UserProfile.LastName = value;
            }
        }
 
      
        
        [Required(ErrorMessage = "User Name Required")]
        [Remote("UserNameExists", "AddUserLogin", "Administration")]
        [DisplayName("User Name:")]      
        public string UserName { get; set; }
        [Required(ErrorMessage = "Email Address Required")]
        [ValidateEmail(ErrorMessage = "A valid email address is required")]
        [DataType(DataType.EmailAddress)]
        [DisplayName("Email Address:")]
        public string Email { get; set; }
}

This identical model works fine in a standard scaffold generated view.  Any ideas?
Henrik
Top achievements
Rank 1
 answered on 16 Jun 2013
4 answers
594 views
Hi,
I have put in a general error handling to handle exceptions and authorisation errors for all Ajax calls, both Kendo and my api. I send back status 500 of exception and 401, Forbidden, or 403, Unauthorized, for authorisation errors.

The problem is I do not seem to be able to prevent the dataSource from updating the display if I get a non-200, OK, response. Looking at the code in Chrome it does not call the function associated with 'databinding' on line 13 of the code below.
01.function kendoGridErrorHandler(args) {
02.    if (args.errors == undefined) {
03.        if (args.xhr.status == 403) {
04.            updatePrimaryMessage("You are not authorised to carry out that operation.", true);
05.        } else if (args.xhr.status == 401) {
06.            updatePrimaryMessage("You need to be logged in to carry out that operation.", true);
07.        } else if (args.xhr.status == 500) {
08.            updatePrimaryMessage("The operation did not complete because of an error.", true);
09.        } else {
10.            updatePrimaryMessage("There was problem. Please refresh the screen.", true);
11.        }
12.        $('#PrimaryKGrid').data().kendoGrid.one('dataBinding', function(e) {
13.            e.preventDefault();
14.        });
15.    } else {
16.        //error means Ajax error response. customerror means Kendo error response
17.        var grid = $('#PrimaryKGrid').data("kendoGrid");
18.        grid.one("dataBinding", function(e) {
19.            e.preventDefault(); // cancel grid rebind if error occurs
20.            //We have formatted errors to display
21.            for (var error in args.errors) {
22.                showMessage(grid.editable.element, error, args.errors[error].errors);
23.            }
24.        });
25.    }
26.}
Can you suggest what I have done wrong?

Thanks in advance.
Jon Smith
Top achievements
Rank 1
 answered on 14 Jun 2013
3 answers
700 views
I am migrating an application from release 2012.3.1114 to release 2013.1.319.  Previously, I was able to apply HtmlAttributes on columns in this manner:
@(Html.Kendo().Grid<ToolListItemView>().Name("texListGrid")
    .Columns(columns => {
        columns.Bound(m => m.ToolId);
        columns.Bound(m => m.Description).HtmlAttributes(new { style = "font-size: 1.3em;" });
        columns.Bound(m => m.LastModified);
        columns.Bound(m => m.ConditionName);
        columns.Bound(m => m.LocationName);
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("ToolsRead", "List").Data("listParams"))
    )
)
With release 2013.1.319, an "invalid template" error is generated from the above code.  If I change HtmlAttributes to HeaderHtmlAttributes, no errors are generated and the style is applied to the column header (i.e. the format of the HtmlAttributes isn't a problem).  I did verify that I could use HtmlAttibutes on a column with an @class parameter successfully, which is the correct way of applying styles.  I guess I'm wondering if this capability (local CSS styling via HtmlAttributes) was intentionally removed, or if I'm doing something wrong?

Note: Moved from Kendo UI Web forum.
Dimo
Telerik team
 answered on 14 Jun 2013
1 answer
83 views
I have read several tutorials and have a few basic questions regarding mobile development and Kendo.
1.  I am building mobile apps with MVC 4 and VS 2012.  Do I only need to use Kendo Mobile UI or do I also use Kendo UI Complete for ASP.Net MVC?  What is the difference?
2.  I also want to use OpenAccess ORM, but do not understand where this integrates with Kendo UI Mobile (is there any good samples)?
3. This will be hosted via Azure websites, is there any gotchas before I moved forward?

Thanks for the help, I must admit it is not very clear which toolset to use at this point.
Jason
Alexander Valchev
Telerik team
 answered on 13 Jun 2013
4 answers
679 views
I have a combobox with over 100000 records, but it's unusable, it makes the browser very slow and unresponsive.

I'm using it like this:
@(Html.Kendo().ComboBox()
    .Name("ID_Poblacion")
    .DataValueField("Item1")
    .DataTextField("Item2")
    .DataSource(dataSource => dataSource // Configure the grid data source
        .Read(read => read.Action("Items", "Poblacion", new { Area = "DataAPI" }))
    )
    .Value(Model.ID_Poblacion.ToString())
)
I've also tried setting Autobind(false), but when I try to open the combobox it becomes unusable.

I've tried limiting the number of records returned, but once it's databoud, it seems it won't call the server method again no matter what I type in the box.

Any help on how to make the combobox usable with huge number of records?
Sergi
Top achievements
Rank 1
 answered on 13 Jun 2013
0 answers
88 views
Hi,
I implemented Kendo Grid helper in a MVC 4 with WebApi application, but I don't know how can I set de column list to change dinamically the rows that it shows.
My code:
@(Html.Kendo().Grid<Bitacora.WebUI.Models.WhiteBoard.XXXGridModel>()
            .Name("Grid")
            .AutoBind(true)
            .EnableCustomBinding(true)
            //.BindTo(Model.xxxx.YYYList)
            .Columns(c =>
            {
                c.AutoGenerate(column =>
                {
                    //customize autogenereted column's settings                                                    
                    column.Width = "150px";
                    
                    //column.ClientTemplate = "<input type='checkbox' name='checkbox' />";

                });
            })
            .Scrollable(scrolling => scrolling.Enabled(true).Height("auto"))
            .Resizable(x => x.Columns(true))
            .Events(events => events.Change("searchCalls"))
            .DataSource(dataSource => dataSource
                                                .Ajax()
                                                .Read(read => read
                                                   .Action("Search", "api/ActionApi")
                                                   .Data("getFiltersSelected")
                                                   .Type(HttpVerbs.Post))
                                                   .ServerOperation(true)) // Paging, sorting, filtering and grouping will be done server-side  
                                                //.ColumnMenu()
                                                .Selectable(selectable => selectable
                                                    .Mode(GridSelectionMode.Multiple))
                                                .Reorderable(reorder => reorder.Columns(true))
                                                .Groupable(grouping => grouping.Enabled(true))
                                                .Filterable(filterable => {filterable
                                                                            .Operators(operators => 
                                                                                        {operators.ForString(strFilter => strFilter.Clear().Contains("contains"));
                                                                                            operators.ForNumber(strFilter => strFilter.Clear());
                                                                                        });
                                                                            filterable.Extra(false);
                                                            }) //--> sólo se muestra el contains en las columnas Texto
            .Sortable(s=> s
                .SortMode(Kendo.Mvc.UI.GridSortMode.MultipleColumn)
                .AllowUnsort(true))
            .Pageable(pager => pager
                .Enabled(true)
                .Input(true)
                .PageSizes(new [] { 5, 10, 20, 30, 40, 50 })) // MULTIDIOMA RESOURCES

My Model:

 public class XXXGridModel
    {
        [Display(Name = "Id", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int Id { get; set; }
         [Display(Name = "DateCreated", ResourceType = typeof(WhiteBoardGridVMResource))]
        public DateTime DateCreated { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string CallNumber { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string FileNumber { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string DUE { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdBranchOffice { get; set; }
         [Display(Name = "BranchOfficeName", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string BranchOfficeOfficeName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdCompany { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string CompanyCompanyName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdOffice { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string OfficeOfficeName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdShip { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string ShipShipName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdPort { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string PortPortName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdCallStatus { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string CallStatusStatusName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int? IdOwner { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string OwnerThirdPartyName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int? IdOperator { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string OperatorThirdPartyName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int? IdInductor { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string InductorThirdPartyName { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public bool IsNominatorOwner { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public bool IsNominatorOperator { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public bool IsNominatorInductor { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public int IdCreatedBy { get; set; }
        [Display(Name = "Default", ResourceType = typeof(WhiteBoardGridVMResource))]
        public string CreatedByUserName { get; set; }
        }

Anyone can Help me?!
Thanks in advance
Ivan
Top achievements
Rank 1
 asked on 13 Jun 2013
1 answer
159 views
Is there a way to edit grid rows in a separate view. I need to accomplish this because the modal has too much information so it needs to be displayed in a separate view.

grid.bind("edit", function (e) {
                window.location = '@Url.Action("AddEditCoalition","Form",new{coalitionId=Model.CoalitionId})' + '&formId=' + e.model.Id;
});
The only problem is the modal shows up is there anyway to do this without the modal showing at all and it goes stratight to the seperate view?
Rosen
Telerik team
 answered on 13 Jun 2013
6 answers
1.0K+ views
Hi,
I'm trying to understand how to bind an action from the Db to the kendo menu. 
in all the demos I saw there is and Item.add().text().action("action","controller");

but if I bind to Db then I have:
Item.Text = "Some Text";

how should I attach the action method to the menu? (what should be the right side of the item.Action = ?)
I would also like your opinion as to the way to store it in the Db (if there is any best practice regrding this matter).

thank you
ShareDocs
Top achievements
Rank 1
 answered on 12 Jun 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?