Telerik Forums
UI for ASP.NET MVC Forum
1 answer
3.4K+ views

I am trying to disable a column which uses a template in a grid. I would like to disable it ONLY if the grid is in Edit mode. I am trying the following as shown below. Can anyone shed some light as to why this does not work and what I need to to do to make this work? Thanks! 

 

@(Html.Kendo().Grid<AMP.Security.Models.UserAccountDto>()
                                  .Name("grid")
                                  .Columns(columns =>
                                  {
                                      columns.Bound(p => p.Account).ClientTemplate("#=Account.Name#");
                                      //columns.Bound(p => p.AccountRoleName);
                                      columns.Bound(p => p.AccountClientName);
                                      columns.Bound(p => p.AccountAdmin);
                                      columns.Command(command => { command.Edit(); command.Destroy();
                                      command.Custom("Configure").Click("configAccount");
                                      }).Width(300);
                                  })
                                          .HtmlAttributes(new { style = "height: 400px;" })
                                  .ToolBar(toolbar => { toolbar.Create().Text("Add Account"); })
                                  .Editable(editable => editable.Mode(GridEditMode.InLine))
                                  .Events(events => events.Edit("onGridEdit"))
                                  .Sortable()
                                   
                                   
                                   
                                  .Scrollable()
                                  .Selectable(a => a.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
                                  .DataSource(datasource => datasource
                                      .Ajax()
                                      .Events(events => events.Error("gridError"))
                                      .ServerOperation(false)
                                      .Model(model =>
                                      {
                                          model.Id(p => p.UserAccountId);
                                          model.Id(p => p.Account);
                                          model.Field(f => f.AccountClientName).Editable(false);
                                          model.Field(f => f.UserId).DefaultValue(Model.UserId);
                                          //model.Field(f => f.AccountRoleId).DefaultValue(ViewData["roledefault"] as int?);
                                          model.Field(f => f.Account).DefaultValue(ViewData["accountdefault"] as AMP.Security.Models.AccountDto);
                                      })
                                      .Read(read => read.Action("UserAccountsRead", "UserProfile", new { userid = Model.UserId }))
                                              .Create(update => update.Action("UserAccountsCreate", "UserProfile"))
                                              .Update(update => update.Action("UserAccountsUpdate", "UserProfile"))
                                              .Destroy(update => update.Action("UserAccountsDestroy", "UserProfile"))
                                      .Sort(sort => sort.Add("AccountName").Ascending())
                                      .PageSize(50)
                                  )
)

The template for the Account column is defined as: 

 

@using Kendo.Mvc.UI
@(Html.Kendo().DropDownListFor(m => m)
    .Name("Account") // Name of the widget should be the same as the name of the property
    .DataValueField("AccountId") // The value of the dropdown is taken from the EmployeeID property
    .DataTextField("Name") // The text of the items is taken from the EmployeeName property
    .BindTo((System.Collections.IEnumerable)ViewData["accounts"])
            )

The onGridEdit function is: 

function onGridEdit(e)
{
    if (e.model.isNew() == false) {
        var cell = $('[name="account"]');
        cell.attr("readonly", true);
        cell.attr("enabled", false)
    }
 }

Radoslav
Telerik team
 answered on 09 Oct 2015
5 answers
224 views

I have this little test with the Gantt Control. The chart always contains 4 levels. How can I make the last level to be a ActionLink?

@(Html.Kendo()
    .Gantt<TaskViewModel,
    DependencyViewModel>((IEnumerable<TaskViewModel>)ViewBag.Tasks,
                        (IEnumerable<DependencyViewModel>)ViewBag.Dependencies)
    .Name("gantt")
    .Columns(columns =>
    {
        columns.Bound(c => c.TaskID).Title("ID").Width(50);
        columns.Bound(Html.GetResourceString("Gantt.Title")+"title").Editable(false).Sortable(true);
        columns.Bound(Html.GetResourceString("Gantt.Start") + "start").Title(Html.GetResourceString("Gantt.StartTime") + "Start Time").Format(Html.GetResourceString("Gantt.DateFormat") + "{0:MM/dd/yyyy}").Width(100).Editable(false).Sortable(true);
        columns.Bound(Html.GetResourceString("Gantt.End") + "end").Title(Html.GetResourceString("Gantt.EndTime") + "End Time").Format(Html.GetResourceString("Gantt.DateFormat") + "{0:MM/dd/yyyy}").Width(100).Editable(false).Sortable(true);
    })

 

Bozhidar
Telerik team
 answered on 09 Oct 2015
3 answers
573 views

I have a test page set up for my issue.  http://http://www.ipapilot.org/test/zurbkendo.aspx

I know that this is because I am using the zurb foundation framework. When I take out the foundation css the numeric text box displays correctly. With Zurb it is 2 rows high if you will.

I wanted to fix this so I began looking at the css to fix it.  Finally I what I have realized is that I believe the kendo javascript is updating the html of the numeric text box element. This overrides ANY css I would want to throw at it to correct the display.

With foundation css the element has display:block in the html

Without foundation css the element has display:inline-block in the html.

 

What part of the javascript does this?  How do I get it to use display:inline-block?  I've tried a formreset.css kind of approach where I reset the css for input elements and such but I can't find the secret sauce. 

 Maybe my analysis is flawed as well.  I would appreciate any help in correcting this.

 

Thanks,

Trevor

Plamen Lazarov
Telerik team
 answered on 08 Oct 2015
1 answer
134 views

 Hello again. What operators are available for the filters? so far i know of eq and neq. Are there any other?

var filter = {
    logic: logic1,
    filters: $.map(selectedObj, function (value) {
        return {
            operator: "eq",
            field: "RoomId",
            value: value
        };
    })
};

Vladimir Iliev
Telerik team
 answered on 08 Oct 2015
1 answer
986 views

Here is my dilema,

I have a foreach loop over a simple model like this

Model

fund list

fundint int,

fundname varchar

etc.

i am looping through a list of funds above and would like to have a Kendo grid populated with data from the controller for each fundint in the foreach.

        <table>
            @foreach (var item in Model)
            {
                <tr>
                    <td>@Html.DisplayFor(modelItem => item.FUND_INT_ID)
                    </td>
                <tr>
                    <td>
                    @(Html.Kendo().Grid<BetaSMTRApp.Models.Private_Report_Card_Companies_Single_Result>()
     .Name("AjaxGrid")
                                .AutoBind(true)                                                                       .Columns(columns =>
             {
                                                                              columns.Bound(c => c.CompanyName).Title("Company Name").Width(150);
                                                                       })
                                                                          .ColumnMenu()
                                                                          .HtmlAttributes(new { style = "height:600px;" })
                                                                          .DataSource(dataSource => dataSource
                                                                              .Ajax()
                                                                              .Read(read => read.Action("GetPortfolioCompanies", "PrivateReportCard").Data("additionalInfo"))
                                                                          )
                                    )
                    </td>
 
<script>
    function additionalInfo() {
        var frominfo = $("#asofdate").val();
        var fundinfo = $("#fundint").val();
        return { AsOfDate: frominfo, FundInt: fundinfo};
    }
</script>

How do i pass the FUND_INT_ID in the foreach loop to the GetPortfolioCompanies function in the controller?

Dimiter Madjarov
Telerik team
 answered on 08 Oct 2015
4 answers
102 views

Hello,

 I've been struggling to get my grid to work with an Web API...I know the WebAPI works when I call it via web browser, I get a properly formatted json response, however I can't seem to get it to work when calling it with the datasource for the grid.  I've tried using .Ajax() and .WebApi() and neither seems to work.

I also created a Action in my controller that returns the same information as the WebAPI just to see if I could get it to work using the Controller / Action and it worked just fine there, but I really wanted to use the Web API.  Here's the code I'm trying to use...can anyone see anything obviously wrong?

 

@(Html.Kendo().Grid<DefectFeature>()
        .Columns(column =>
        {
            column.Bound(df => df.Name)
                .Title("Name");
            column.Bound(df => df.LastUpdate)
                .Title("Last Update");
        })
        .DataSource(dataSource => dataSource
            .WebApi()
            .Read(read => read.Url("http://cmd-roswell.redmond.corp.microsoft.com/api/DataMaintenance/GetDefectFeatures").Type(HttpVerbs.Get)))
        .HtmlAttributes(new { style = "height:300px;" })
        .Name("LKGBuildsGrid")
        .Scrollable()
        .Selectable()
        .Sortable())

Kiril Nikolov
Telerik team
 answered on 08 Oct 2015
6 answers
1.8K+ views
Hello can you give me the exact link to get kendo.common-bootstrap.min.css via CDN? 

This one is not working


Your link http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/asp-net-mvc-5 seem show incorrect information about that :

Using Kendo UI CDN
 
To include the Kendo UI JavaScript and CSS files from CDN follow these steps. Important! Don't forget to replace "kendo ui version" from the code snippets below with the current version of Kendo UI e.g. "2013.2.918".
1.Open the layout of the application. By default it is Views/Shared/_Layout.cshtml (or Site.master if using ASPX).
 
2.Include kendo.common-bootstrap.min.css and kendo.bootstrap.min.css. Add a link tag within the head tag of the layout.
 
<link rel="stylesheet" href="http://cdn.kendostatic.com/<;kendo ui version>/styles/kendo.common-bootstrap.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/<;kendo ui version>/styles/kendo.bootstrap.min.css" />
Alex Gyoshev
Telerik team
 answered on 08 Oct 2015
5 answers
938 views

Hello,

 I'm trying to get a kendo Grid to load using Ajax from within a Tabstrip using Ajax.  The UI for the grid seems to load just fine, however the Action for filling the grid never seems to get called.  Before moving it to be loaded from within the Tabstrip, the grid worked just fine...so it's gotta be some sort of syntax thing about how I'm loading it.

 I'm using the same controller for actions to load the Tabstrip view (DataMaintenanceView), the grid view (DefectFeatureView), and the action for returning the results to the grid (GetDefectFeatures).

 Please take a look at my controller and views and let me know if there's anything I'm doing wrong...thx in advance!  :)

DataMaintenanceController:

 

public class DataMaintenanceController : Controller
{
    #region View Actions
    [HttpGet]
    public ActionResult DataMaintenanceView()
    {
        return View();
    }
 
    /// <summary>
    /// default view for the DataMaintenance controller
    /// </summary>
    /// <returns>the default DataMaintenanceView</returns>
    [HttpGet]
    public ActionResult DefectFeatureView()
    {
        return View("DefectFeatureView");
    }
    #endregion
 
    #region Actions for adding data
    /// <summary>
    /// adds a new DefectFeature into the database
    /// POST: api/ServerToSwitch/AddDefectFeature?name=[nameValue]
    /// </summary>
    /// <param name="name">name of DefectFeature to add</param>
    [HttpPost]
    public ActionResult AddDefectFeature(string name)
    {
        DataMaintenance dataMaintenance = new DataMaintenance(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
        dataMaintenance.AddDefectFeature(name);
 
        return RedirectToAction("DataMaintenanceView");
    }
    #endregion
 
    #region Actions for retrieving data
    /// <summary>
    /// retrieves all DefectFeature objects from the database
    /// GET: /DataMaintenance/GetDefectFeatures
    /// </summary>
    /// <returns>a collection of DefectFeature objects</returns>
    [HttpGet]
    public ActionResult GetDefectFeatures([DataSourceRequest] DataSourceRequest request)
    {
        DataMaintenance dataMaintenance = new DataMaintenance(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
        var defectFeaturesPayload = dataMaintenance.GetDefectFeatures().Payload;
 
        DataSourceResult result = defectFeaturesPayload.ToDataSourceResult(request);
        return Json(result);
    }
    #endregion
}

DataMaintenanceView

@using TPOReporting
@model DataMaintenance
 
@{
    ViewBag.Title = "3rd Party Optics Reports - Data Maintenance";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
 
<script>
    function Sleep(milliSeconds)
    {
        var startTime = new Date().getTime();
 
        while (new Date().getTime() < startTime + milliSeconds);
    }
</script>
 
<div>
    <br />
    <br />
    <h2>3rd Party Optics Reports - Data Maintenance</h2>
</div>
<div>
    <br />
    <div>
        @(Html.Kendo().TabStrip()
            .Name("DataMaintenanceTabStrip")
            .Items(i =>
            {
                i.Add().Text("Defect Feature Maintenance")
                    .LoadContentFrom("DefectFeatureView", "DataMaintenance")
                    .Selected(true);
            })
        )
    </div>
</div>

DefectFeatureView

@using TPOReporting
@model DataMaintenance
 
@{
    ViewBag.Title = "Defect Feature Maintenance";
}
 
<script>
    function NewDefectFeatureSubmitButtonClick(e)
    {
        var defectFeatureGrid = $("#DefectFeatureGrid").data("kendoGrid");
        var newDefectFeatureTextBox = $("#NewDefectFeatureNameTextBox");
 
        var newDefectFeatureName = newDefectFeatureTextBox.val();
 
        var dummyUrl = '@Url.Action("AddDefectFeature", "DataMaintenance", new { name = "V1" })';
        var url = dummyUrl.replace("V1", newDefectFeatureName);
 
        $.ajax(
        {
            type: "POST",
            url: url,
            dataType: "json"
        });
 
        Sleep(1000);
        defectFeatureGrid.dataSource.read();
        newDefectFeatureTextBox.val("");
    }
</script>
 
<div>
    <table>
        <tr>
            <td>
                <label>New Defect Name:</label>
            </td>
            <td>
                @(Html.Kendo().TextBox()
                        .Name("NewDefectFeatureNameTextBox"))
            </td>
            <td>
                @(Html.Kendo().Button()
                        .Name("NewDefectFeatureSubmitButton")
                        .Content("Submit")
                        .Events(e => e.Click("NewDefectFeatureSubmitButtonClick")))
            </td>
        </tr>
    </table>
</div>
<div id="defectFeatureDiv">
    @(Html.Kendo().Grid<DefectFeature>()
          .Columns(column =>
          {
              column.Bound(df => df.Name)
                  .Title("Name");
              column.Bound(df => df.LastUpdate)
                  .Title("Last Update");
          })
          .DataSource(dataSource => dataSource
              .Ajax()
              .Read(read => read.Action("GetDefectFeatures", "DataMaintenance")))
          .HtmlAttributes(new { style = "height:300px;" })
          .Name("DefectFeatureGrid")
          .Scrollable()
          .Selectable()
          .Sortable())
</div>

Boyan Dimitrov
Telerik team
 answered on 07 Oct 2015
6 answers
1.0K+ views
I have a parent grid / child grid. and I can't seem to get the two working properly.  Using the DetailInit event to set the data for the child grid, but the event is not even firing.  The grids are server bound with a model.  Here is the razor code.  Thanks for the help.
Dan

​
@model IEnumerable<EquipmentsSummary>
 
<div class="info-row">
    @(Html.Kendo().Grid(Model)
        .Name("EquipmentGrid")
        .Columns(columns =>
        {
            columns.Bound(e => e.EquipName).Title("Item Name");
            columns.Bound(e => e.SerialNo).Title("Serial #");
            columns.Bound(e => e.AssetStatus).Title("Status");
            columns.Bound(e => e.AssetStatusDate).Title("Date");
        })
        .HtmlAttributes(new { style = "height: 390px;" })
        .Pageable(pageable => pageable
            .PageSizes(true).PageSizes(new int[] { 20, 50, 100 })
            .ButtonCount(5))
        .Sortable()
        .Filterable()
        .Scrollable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(20)
            .ServerOperation(false))
        .ClientDetailTemplateId("template")
        .Events(events => events.DetailInit("initDetail"))
    )
 
    <script id="template" type="text/kendo-tmpl">
        @(Html.Kendo().Grid<EquipmentSettingsSummary>()
            .Name(string.Format("SettingGrid_#=ID#"))
            .Columns(columns =>
            {
                columns.Bound(e => e.EffectiveDate).Title("Date");
                columns.Bound(e => e.AssetStatus).Title("Status");
            })
            .HtmlAttributes(new { style = "height: 390px;" })
            .Pageable(pageable => pageable
                .PageSizes(true).PageSizes(new int[] { 20, 50, 100 })
                .ButtonCount(5))
            .Sortable()
            .Filterable()
            .Scrollable()
            .ToClientTemplate()
        )
    </script>
    <script>
        function initDetail(e) {
            alert("ID is " + e.data.ID);
            var grid = $("#SettingGrid_" + e.data.ID).data("kendoGrid");
            grid.dataSource.data(e.data.SettingItems);
        }
    </script>
</div>
Rosen
Telerik team
 answered on 07 Oct 2015
1 answer
184 views

Hello all, 

I have grid which displays a group of records.  Then some custom actions to perform on this records. One of the custom actions will open a popup window which displays another grid with child information about the original table.  I'm doing this by passing a custom query string with the parent key.

 In this child table, when I try to create a new record, the foreign key that is passing to the controller is 0 event though when editing, the binding will show the correct value. Through jquery I'm able to read the parentID and put it in a hidden field in the child screen, but when submitting, is goes as 0 again even though it has a number on it.  The only way I'm able to solve the issue is by passing a value directly to the model in the child window in the OnEdit event like this:

 

    e.model.set("GroupID", $("#txtGroupID").val());

 

Anyone knows why is passing a 0 value although I'm assigning a value for it: $("#GroupID").val($("#txtGroupID").val());

Any recommendations?

Rosen
Telerik team
 answered on 07 Oct 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
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
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
Iron
Iron
Sergii
Top achievements
Rank 1
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
Iron
Iron
Sergii
Top achievements
Rank 1
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?