Telerik Forums
UI for ASP.NET MVC Forum
2 answers
188 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. I don't want put all columns, only a list of columns pre-selects by diferents criterials (user config preferences).

My Helper 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
balazs
Top achievements
Rank 2
Iron
 answered on 24 Sep 2015
2 answers
192 views

I recently came across a strange issue happening with the kendo Scheduler regarding firing off change events.

I have a custom event handler set so that when a user clicks on an item in the Scheduler it opens a link to a separate details page (in a new tab). The problem is that after doing this, other (unrelated) UI elements in the Scheduler will fire off the exact same event when I click on them.

You can actually see this behavior on the Scheduler Events sample page here: http://demos.telerik.com/kendo-ui/scheduler/events

To replicate:
Click on the Month View button.
Click on (highlighting) the item "HR Lecture", on the 06th. This will fire off a Change event.
Now click on the Month View button again. In between the dataBinding and dataBound events, another Change event will fire off for the same time slot. (Prior to clicking on HR Lecture, this is not the case. You'll only see events for navigation, dataBinding, and dataBound events)

This doesn't seem to happen with all events, HR Lecture just appears to be one that *does* trigger the behavior.

Is this expected? If so, is there any way to prevent this from happening?

 

Edward
Top achievements
Rank 1
 answered on 23 Sep 2015
4 answers
251 views
Hello all,

I have a grid with a date filter, if I pick the date from the date picker included in the filter it all works fine.

If I enter the date as 06/17/2013 that works fine, but on the other hand if I enter the date 06/17/13 (2 digit year) I do not get results back.

What can I do to over come this issues. 
Brad Fulton
Top achievements
Rank 1
 answered on 23 Sep 2015
11 answers
1.2K+ views

I want to have a Kendo Grid with several columns. I am able to create a Kendo Grid with several columns and it has horizontal scroll bar. The columns are able to scroll horizontally, But the grid column names (column header names) does NOT scroll horizontally.
I also referred to the link : "http://www.telerik.com/forums/horizontal-scroll-bar-in-grid-but-not-working-for-header-".

I tried several things (like changing jquery version etc) but the problem is NOT resolved.
Can you let us know what am I missing?

The Kendo version we are using is Q1 2014 (2014.1.415).

---------------------------------------------------------------------


Following is the code snippet from Index.cshtml.


<script src="../../../../Scripts/kendo/2014.1.415/jquery.min.js" type="text/javascript"></script>

<script src="../../../../Scripts/kendo/2014.1.415/kendo.all.min.js" type="text/javascript"></script>


<script src="../../../../Scripts/kendo/2014.1.415/kendo.aspnetmvc.min.js" type="text/javascript"></script>


 @(Html.Kendo().Grid((IEnumerable<TelerikMvcApp1.Areas.UIConfig.Models.GenericUIClass>)ViewBag.GridData)


      .Name("grid")
      .Columns(columns =>
      {



          foreach (string key in ViewBag.Columns.Keys)
          {
              List<string> value = ViewBag.Columns[(string)key];



              columns.Bound(genericUI => genericUI.column1).Width(200).Title(key);
             

          }
         
         

      })

       .Scrollable(s => s.Enabled(true))
Joseph
Top achievements
Rank 1
 answered on 22 Sep 2015
1 answer
230 views

Hi all,

I am trying to display an object in a Kendo grid in a MVC Website, however this object contains a dictionary and it seems like the grid is unable serialize it.

This is the error message I am getting:

Type 'System.Collections.Generic.Dictionary`2[[ExactModels.SalesOrderLine, ExactModels, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[ExactModels.Item, ExactModels, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' is not supported for serialization/deserialization of a dictionary, keys must be strings or objects.

I am using Kendo.Mvc.dll version 2015.2.902.545.

And this is the object which contains the dictionary that is causing the problem.

public class CustomOrder
{
    [Key]
    public Guid ID { get; set; }
    //public SalesOrder salesOrder { get; set; }
 
    private SalesOrder order;
     
    public SalesOrder salesOrder
    {
        get { return order; }
        set
        {
            order = value;
            if (order != null)
            {
                this.ID = order.OrderID;
            }
        }
    }
 
    public Account account { get; set; }
    public Dictionary<SalesOrderLine, Item> salesOrderLineItem { get; set; }
    public Boolean Checked { get; set; }
}

Anyone any idea of how to fix this?

Thanks in advance.

Rosen
Telerik team
 answered on 22 Sep 2015
2 answers
5.4K+ views

Please find the below code as i want to set default value of dropdown instead of optionlable from  JSON data which is returned
from controller .
 
Please find the below code

public ActionResult GetOrders()
       {
           List<usp_IDQ_GetLicenseDistrictsVO> objresult1 = new List<usp_IDQ_GetLicenseDistrictsVO>();
           objresult1 = objConnection.usp_IDQ_GetLicenseDistricts(User.Identity.Name, true).ToList();
           return Json(objresult1, JsonRequestBehavior.AllowGet); ;
       }

@(Html.Kendo().DropDownList()
              .Name("DropDownList1")

                      //.Events(ev => ev.DataBound("SalesPersonID_DataBound"))
                      .OptionLabel("Select ...")
              .HtmlAttributes(new { style = "width:300px" })
              .OptionLabel("Select ...")
              .DataTextField("District_Id")
              .DataValueField("Location_ID")


                      .DataSource(source =>
           {
               source.Read(read =>
                  {
                      read.Action("GetOrders", "IDTDashboard");
                  })
                  .ServerFiltering(true);
           })
           .AutoBind(false)


Kiril Nikolov
Telerik team
 answered on 22 Sep 2015
4 answers
800 views
How do I disable the automatic conversion to the client timezone. I want the scheduler to display the date and time I tell it to without it converting to the users local timezone. I am displaying flight data and the users have the ability to plot the events in UTC, at a given airport or their timezone. I convert these dates manually in SQL and return them to the UI. Is this possible or is there some workaround I can put in place. 
Vladimir Iliev
Telerik team
 answered on 22 Sep 2015
1 answer
213 views

I would like to setup a validation rule that would conditionally be applied.  For example

I have three fields

Status:  Enum field (​pending, approved, denied)
Denied Code: (price, qty, misc..., ect...)
Comment (Long text)

 

So if the Status is equal to denied I want the Denied Code and Comment to require an update otherwise ignore them.  Is this possible? and if so how would I go about doing this?  Also the value of the Denied Code must not equal none. 

 My Index page:

<style>
    .cont {
  padding-right: 10%;
  padding-left: 10%;
  margin-right: auto;
  margin-left: auto;
}
</style>
 
<div class="cont">
  @(Html.Kendo().Grid<Portal.Model.DAX.PurchaseJournalTransaction>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.PurchId).Title("Order Id").Width(120);
        columns.Bound(c => c.LineNum).Title("Line").Width(80).Hidden(true).IncludeInMenu(true);
        columns.Bound(c => c.ItemId).Width(120);
        columns.Bound(c => c.ExternalItemId).Title("External Id").Width(120);
        columns.Bound(c => c.Name).Width(400);
        columns.Bound(c => c.DeliveryDate).Width(140).Format("{0:MM/dd/yy}");
        columns.Bound(c => c.PurchUnit).Width(75).Title("Unit");
        columns.Bound(c => c.Quantity).Width(120).Format("{0:#,##0}");
        columns.Bound(c => c.PurchasePrice).Width(100).Title("Price").Format("{0:$ #,##0.00}");
        columns.Bound(c => c.LineAmount).Width(160).Hidden(true).IncludeInMenu(true).Format("{0:$ #,##0.00}");
        columns.Bound(c => c.LineDiscount).Width(80).Hidden(true).IncludeInMenu(true);
        columns.Bound(c => c.LinePercent).Width(80).Hidden(true).IncludeInMenu(true);
        columns.Bound(c => c.ApprovalStatus).Width(130).EditorTemplateName("ApprovalStatusEditor").Title("Status");
        columns.ForeignKey(c => c.ApprovalReasonId, (System.Collections.IEnumerable)ViewData["ApprovalReason"], "Id", "Description").Width(350).Title("Denied Code");
    })
    .ToolBar(toolbar =>
    {
        toolbar.Excel();
        toolbar.Save();
    })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Pageable(p => p.PageSizes(true).PageSizes(new int[] {20,50,100,1000}))
    .Navigatable()
    .Filterable(filtering => filtering.Enabled(true))
    .Groupable()
    .Sortable(s => {
        s.SortMode(GridSortMode.MultipleColumn);
        s.AllowUnsort(true);
        })
    .ColumnMenu()
    .Scrollable(scrollable => {
        scrollable.Enabled(true);
        scrollable.Height(700);
        })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Model(model => {
            model.Id(p => p.CompanyId);
            model.Field(c => c.PurchId).Editable(false);
            model.Field(c => c.LineNum).Editable(false);
            model.Field(c => c.ItemId).Editable(false);
            model.Field(c => c.ExternalItemId).Editable(false);
            model.Field(c => c.Name).Editable(false);
            model.Field(c => c.CurrencyCode).Editable(false);
            model.Field(c => c.PriceUnit).Editable(false);
            model.Field(c => c.Quantity).Editable(false);
            model.Field(c => c.PurchUnit).Editable(false);
            model.Field(c => c.PurchasePrice).Editable(false);
            model.Field(c => c.DeliveryDate).Editable(false);
            model.Field(c => c.LineAmount).Editable(false);
            model.Field(c => c.LineDiscount).Editable(false);
            model.Field(c => c.LinePercent).Editable(false);
             
        })       
        .Read(read => read.Action("PurchaseJournalTransactions_Read", "Approval"))
        .Update(update => update.Action("PurchaseJournalTransactions_Update", "Approval"))
      )
    )
    <br />
</div>

Petyo
Telerik team
 answered on 21 Sep 2015
1 answer
108 views

Hello, I just started working with the product.  I created a grid using the MVC control.  Also, the grid is using a custom pop up form when editing/creating a record.

 Inside that custom form, I added a multiselect control. The control should reference values stored in a child table from the record, basically I want to store multiples agencies a person can belong to.  The model have a reference to the child table. 

When submitting the form, the entity object knows that I ​selected X amount of companies, but I cant get to the values. What is the best way of doing this for a child table?

 

<label for="Agency" class="required col-sm-3 control-label" style="text-align:left;margin-right:-55px">Insurance Companies</label>
            @(Html.Kendo().MultiSelect()
                  .Name("tblAgentInsurers")
                  .DataTextField("InsuranceAgencyName")
                  .DataValueField("InsuranceAgencyID")
                  .Placeholder("Select agencies...")
                  .HtmlAttributes(new { @class = "col-sm-2 form-control", style = "width:70%; height:auto; min-height: 34px;" })
                  .AutoBind(false)
                  .Filter(FilterType.Contains)
                  .DataSource(source =>
                  {
                      source.Read(read =>
                      {
                          read.Action("GetAgencies", "Agents");
                      })
                      .ServerFiltering(true);
                  })
            )​

 

MiracleMan
Top achievements
Rank 1
 answered on 21 Sep 2015
3 answers
693 views

Hi 

I have textbox, a button and a Grid in my screen, i am binding data to it on a button click with the textbox input.

If the user clicks the button again with different inputs, i have to go to DB, get data  and append the new data to the existing Grid data.

I should not lose the existing data and i need to append new data to the same grid I should be able to call the same URL to get data.

Please let me know how I can achieve this.

 

Sample Code: 

<input type="text" class="k-textbox"/>

<button id="btnAdd">Add</button></td>

<div id="grid"></div>
<script>

 $("#btnAdd").on('click', function () {

$("#grid").kendoGrid({
                dataSource: {
                    type: "json",
                    transport: {
                        read:
                            {
                                url: // my url with textbox inputs,
                                cache: false
                            }
                    },
schema: {
                        model: {
                            fields: {
ID: {type: "string"},
Name: {type: "String"}
   }
                        }
                    },

 columns: [
                //{ hidden: true, field: "AssetID", editable: false },
                { template: "<input type='checkbox' class='checkbox' />" },
                { field: "ID"},
                { field: "Name"}]
 }).data("kendoGrid");
});
});

</script>

 

 

Petyo
Telerik team
 answered on 21 Sep 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?