Telerik Forums
UI for ASP.NET MVC Forum
2 answers
206 views

For some reason my DatePickerFor isn't working. It's height is always only 39px. So all I can see is pretty much the header. A photo of the issue is attached. Here's the code for the DatePickerFor:

<div class="row">
  <div class="col-sm-4 col-md-3">
    @Html.LabelFor(m => m.DATEFROM, translator.Translate("DATEFROM"), new
    {
      @class = "control-label"
    })
   @(Html.Kendo().DatePickerFor(m => m.DATEFROM).Format("dd.MM.yyyy").HtmlAttributes(new
   {
     style = "width:100%;"
   }))
  </div>
</div>

 

Jokull
Top achievements
Rank 1
 answered on 11 Feb 2017
2 answers
273 views

I'm trying to launch a view which just has a grid in it, but I want to pass in an id to filter the read from the db

Maybe someone can point out what I'm doing wrong.

Here is my call, although I think I really want the read transport

                    @Html.ActionLink("Good Sample List", "Index", "Grid", null, null) @*This works but reads all the rows*@
                    @Html.ActionLink("Sample List", "Index", "Grid", new { id = Model.id }, null) @*This Doesn't*@

What happens is with both calls the Index constructor gets called.  When I don't send in an id it calls the AttributeOptions_Read next.

If I call it with an id the Index constructor get called  with the correct id, then it calls it without an id.  The AttributeOptions_Read is never called.

Here is the controller with some code commented out and using test data instead of my real data.  Hopefully this works the same as on my system.

Code was generated with the Kendo UI Scaffolder

using System;
 using System.Collections.Generic;
 using System.Data.Entity;
 using System.Linq;
 using System.Web.Mvc;
 using Kendo.Mvc.Extensions;
 using Kendo.Mvc.UI;
 //using riteTIME_WebApi.Data;
 
namespace riteTIME_WebApi.Controllers.MVC
{
    public class TestData
    {
        public Guid id { get; set; }
        public Guid attribute_id { get; set; }
        public string value { get; set; }
    }
    public class GridController : Controller
    {
 
        // Generated
        public ActionResult Index()
        {
            return View();
        }
 
        // My version, doesn't do what I expect.
        //public ActionResult Index(Guid? id)
        //{
        //    return View();
        //}
 
        public ActionResult AttributeOptions_Read([DataSourceRequest]DataSourceRequest request)
        {
 
            // I would like to be able to query the db using the attribute_id
 
            var options = new List<TestData>();
 
            options.Add(
                new TestData
                {
                    id = new Guid("1B7EC29F-E2D8-E611-8114-00155DDF5703"),
                    attribute_id = new Guid("F5352D7F-E2D8-E611-8114-00155DDF5703"),
                    value = "Test1 A"
                });
            options.Add(new TestData
            {
                id = new Guid("1C7EC29F-E2D8-E611-8114-00155DDF5703"),
                attribute_id = new Guid("F5352D7F-E2D8-E611-8114-00155DDF5703"),
                value = "Test2"
            });
            options.Add(new TestData
            {
                id = new Guid("1D7EC29F-E2D8-E611-8114-00155DDF5703"),
                attribute_id = new Guid("F5352D7F-E2D8-E611-8114-00155DDF5703"),
                value = "Test3"
            });
            IQueryable<TestData> attributeoptions = options.AsQueryable();
 
            DataSourceResult result = attributeoptions.ToDataSourceResult(request, attributeOption => new
            {
                attributeOption.id,
                attributeOption.value,
                attributeOption.attribute_id
            });
 
            return Json(result);
        }
 
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult AttributeOptions_Create([DataSourceRequest]DataSourceRequest request, TestData attributeOption)
        {
            if (ModelState.IsValid)
            {
                //var entity = new AttributeOption
                //{
                //    value = attributeOption.value
                //};
 
                //db.AttributeOptions.Add(entity);
                //db.SaveChanges();
                attributeOption.id = Guid.NewGuid();
            }
 
            return Json(new[] { attributeOption }.ToDataSourceResult(request, ModelState));
        }
 
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult AttributeOptions_Update([DataSourceRequest]DataSourceRequest request, TestData attributeOption)
        {
            if (ModelState.IsValid)
            {
                //var entity = new AttributeOption
                //{
                //    id = attributeOption.id,
                //    value = attributeOption.value
                //};
 
                //db.AttributeOptions.Attach(entity);
                //db.Entry(entity).State = EntityState.Modified;
                //db.SaveChanges();
            }
 
            return Json(new[] { attributeOption }.ToDataSourceResult(request, ModelState));
        }
 
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult AttributeOptions_Destroy([DataSourceRequest]DataSourceRequest request, TestData attributeOption)
        {
            if (ModelState.IsValid)
            {
                //var entity = new AttributeOption
                //{
                //    id = attributeOption.id,
                //    value = attributeOption.value
                //};
 
                //db.AttributeOptions.Attach(entity);
                //db.AttributeOptions.Remove(entity);
                //db.SaveChanges();
            }
 
            return Json(new[] { attributeOption }.ToDataSourceResult(request, ModelState));
        }
 
        protected override void Dispose(bool disposing)
        {
            //db.Dispose();
            base.Dispose(disposing);
        }
    }
}

 

<div id="grid"></div>
<script>
    $("#grid").kendoGrid({
        height: 400,
        columns: [
            { field: "value" },
            { hidden: true, field: "id" },
            { hidden: true, field: "attribute_id" },
            {command: [ "edit" , "destroy"], width: 180 }
        ],
        toolbar: ["create"],
        dataSource: {
            type: "aspnetmvc-ajax",
            transport: {
                read: {
                     url: "AttributeOptions_Read"
                },
                create: {
                    url: "AttributeOptions_Create"
                },
                update: {
                    url: "AttributeOptions_Update"
                },
                destroy: {
                    url: "AttributeOptions_Destroy"
                }
            },
            schema: {
                data: "Data",
                model: {
                    id: "id",
                    fields: {
                        //id: { type: "number"},
                        value: { type: "string" }
                        // attribute_id:{ type: "number"}
                    }
                }
            },
            serverPaging: true,
            serverSorting: true,
            serverSorting: true,
        },
        editable: "inline",
        scrollable: true
    })
 
</script>
Jeff
Top achievements
Rank 1
 answered on 10 Feb 2017
1 answer
114 views

Hi people.

I'm implementing PivotGrid on my ASP.NET MVC application. With the Grid component, I was able to make filters based on a selection of which values I want due to bounded columns capture feature.

Is there something like this on PivotGrid?

In Grid component. I've done the filter just like this:

                    var bounded = gridColumns.Bound(dataTableCol.GetType(), dataTableCol.ToString());
                    // If the column has a multicheckbox filter - set it based on column definition
                    var customFilterColumn = Model.columns.SingleOrDefault(item => item.ColumnName.Equals(dataTableCol.ToString()));
                    if (customFilterColumn != null)
                    {
                        bounded.Filterable(ftb => ftb
                            .Multi(true)
                            .Cell(cell =>
                            cell.DataSource(ds =>
                                // This is the action that will return the filter unique values
                                ds.Read("MultiFilter_read", "Consulta", new { columnId = customFilterColumn.Id }))));
                        bounded.Width(300);
                    }

 

In "Consulta/MultiFilter_read" action I make a search on database returning the possible values for that column, applying them to the respective bounded column. This instructions I've put on Columns property of the Grid HtmlHelper, and I'm doing PivotGrid with HtmlHelpers too.

 

Angel Petrov
Telerik team
 answered on 10 Feb 2017
1 answer
522 views

Hi,

I'm using the following template to display values in a ComboBox:

.Template("Name: <strong>#: data.FirstName # #: data.LastName #</strong> Organisation: #: data.Organisation #<br>Email: #: data.Email #, Telephone: #: data.Telephone # <br>-----------------------------")

It's working fine except that null values from the database are actually displayed as 'null' in the display. For example, Name: null null Organisation: null.

I've tried filtering the data on the server so it replaced null values with "" but that didn't seem to work.

How can I replace the text 'null' with just a blank value?

Thanks

Tim

Ivan Danchev
Telerik team
 answered on 10 Feb 2017
3 answers
141 views

I cannot select 0 in the example below. I could convert the data to a string type but that would not fit the underlying data. Does anybody have a fix for this issue?

 

 

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Kendo UI Snippet</title>

    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2017.1.118/styles/kendo.common.min.css"/>
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2017.1.118/styles/kendo.rtl.min.css"/>
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2017.1.118/styles/kendo.silver.min.css"/>
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2017.1.118/styles/kendo.mobile.all.min.css"/>

    <script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="http://kendo.cdn.telerik.com/2017.1.118/js/kendo.all.min.js"></script>
</head>
<body>
  
<input id="dropdownlist" />
<script>
  $("#dropdownlist").kendoDropDownList({
    dataSource: [ 0, 1 ],
    optionLabel: "Select"
  });
</script>
</body>
</html>

Ivan Danchev
Telerik team
 answered on 10 Feb 2017
2 answers
254 views
public ActionResult AgentIndex([DataSourceRequest] DataSourceRequest request, string agencyNum)
    {
        
        using (var CB = new CentralBillingEntities())
        {
            var result = CB.GetAgentViewInfo(agencyNum).ToList();
            return Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
        
    }     

 

When I set a breakpoint I actually see the value for my GetAgentViewInfo coming through. But, the grid just flashes and the data never comes back. What am I doing wrong?

Here's the rest of my code:

 

@model IEnumerable<CentralBilling.Models.CentralBillingEntities>
@{
    ViewBag.Title = "View";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="center">
    <h3><u>Agent View</u></h3>
 </div><br />
 
<div>
    @(Html.Kendo().DropDownList()
        .Name("ddlAgency")
        .Events(e => e.Change("agencyChange"))
        .BindTo(new List<SelectListItem>()
          {
                new SelectListItem() { Text = "" },
                new SelectListItem() { Text = "250-Louisville", Value = "U00250" },
                new SelectListItem() { Text = "590-OKC", Value = "U00590"},
          }
 
    ))
</div>
    <div>
 
@(Html.Kendo().Grid<CentralBilling.Models.GetAgentViewInfo_Result>()
         .Name("gridAgent")
         .DataSource(datasource => datasource
         .Ajax()
         .Read(read => read.Action("AgentIndex", "Agent")))
         .Columns(columns =>
                {
 
                columns.Bound(o => o.Req).Width("130px").Title("Request Submission").Template(
                    @<text>
                        @Html.ActionLink("GetAgentDetail", "Agent", new { controller = "Agent", id = item.Full_Order_Number })
                    </text>
                         ).ClientTemplate(@"<a href=/Agent/GetAgentDetail?id=#= Full_Order_Number #>#= Req #</a>");
 
                    columns.Bound(o => o.Master_OrderNum).Width("150px");
                    columns.Bound(o => o.Shipper).Width("175px");
                    columns.Bound(o => o.aom_shipment_type).Title("MoveType").Width("100px");
                    columns.Bound(o => o.AccountHeader).Width("150px");
                    columns.Bound(o => o.EarlyLoadDate).Format("{0:MM/dd/yyyy}").Width("135px");
                    columns.Bound(o => o.Date_Delv_Act).Format("{0:MM/dd/yyyy}").Width("135px");
                    columns.Bound(o => o.Book_Agent).Width("135px");
                    columns.Bound(o => o.Haul_Agent).Width("135px");
                    columns.Bound(o => o.Org_Agent).Width("135px");
                    columns.Bound(o => o.Dest_Agent).Width("135px");
                })
 
                .HtmlAttributes(new { style = "height: 550px" })
                .Resizable(resize => resize.Columns(true))
                .Sortable()
                .Scrollable()
                .Filterable()
        )
 
 
    </div>
 
<script type="text/javascript" language="javascript">
 
    function agencyChange() {
        var ddlAgency = $("#ddlAgency").val();
        alert("Drop down list value is: " + ddlAgency);
        $.get('/Agent/AgentIndex', { agencyNum: ddlAgency }, function (data) {
            onDataUpdated();
     });
}
function onDataUpdated() {
    var grid = $("#gridAgent").data("kendoGrid");
    grid.dataSource.read();
}
</script>
Nick
Top achievements
Rank 1
 answered on 09 Feb 2017
25 answers
1.0K+ views
Using UTC time on both client and server sides.
This project shows how to keep a DateTime property in UTC format on both server and client sides when using a Grid with Ajax Binding and editing.     

Kendo UI
Top achievements
Rank 1
 answered on 09 Feb 2017
1 answer
155 views

I have a column ("Sequence") that will contain an integer. Is there some way to bind the column ("Sequence")'s value to the order?

 

I'd like to use the Sortable control with a Grid so that when they drag the row it will change the Sequence column's value to reflect the order.

 

How can I go about doing this?

Konstantin Dikov
Telerik team
 answered on 09 Feb 2017
3 answers
179 views
Hi,

I am using kendo grids, and the default kendo popup works in most cases, but in some advanced cases I have to popup a modal window using jQuery dialog.

I do this like so:

<div id="popupEdit">
    <div id="dataContainer">
    </div>
</div>

$(function () {
        $("#popupEdit").dialog({
            autoOpen: false,
            height: 470,
            width: 650,
            modal: true
        });

        $("#addItem")
                .button()
                .click(function () {
                    $("#popupEdit").dialog("open");
                });
    });


The jQuery popup doesn't look nearly as nice as the kendo grid popup window.
How can I style the jQuery dialog popup to look very similar to the kendo grid popup??  
Has anybody done this before??

The dataContainer div gets loaded via ajax when something happens on the screen.
Unless there is a way to popup a kendo window that would make it look like the grid popup?


Regards.
Vladimir Iliev
Telerik team
 answered on 09 Feb 2017
3 answers
779 views

Hello!

I have this editor template: @Html.Kendo().TextBoxFor(model => model).Format("{0:n3}")

When I use this editor template to create a form, the numbers get formatted according to the format string with three decimal digits.

But when I use the editor template for a grid column (in-cell / batch editing), the format option is ignored. Instead, numbers are shown exactly the way they are delivered from the server.

However, grid client templates work perfectly:
columnTest.Format("{0:n3}"); // or
columnTest.ClientTemplate("#: kendo.toString('columnTest', 'n3') #");

How can I configure the numeric formatting of the editor templates?

 

Best regards,

Kaan

 

Milena
Telerik team
 answered on 08 Feb 2017
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
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
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
Security
ColorPicker
DateRangePicker
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
DropDownButton
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
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
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?