Telerik Forums
UI for ASP.NET MVC Forum
6 answers
533 views

I have implemented inline editing with Knedo UI MVC grid with Ajax binding, Server side validation handled in controller and sending the error back using -

ModelState.AddModelError("Error: ", ex.Message);

@(Html.Kendo().Grid<AnalyticsServiceWeb.ViewModel.SomeViewModel>() .Name("Grid") .Columns(columns => { columns.Bound(p => p.Name); columns.Bound(p => p.Path); columns.Bound(p => p.Space); columns.Command(command => { command.Edit(); command.Destroy(); }); }) .ToolBar(toolbar => toolbar.Create()) .Editable(editable => editable.Mode(GridEditMode.InLine)) )

function error_handler(e) {
    if (e.errors) {
        var message = "Errors:\n";
        $.each(e.errors, function (key, value) {
            if ('errors' in value) {
                $.each(value.errors, function () {
                    message += this + "\n";
                });
            }
        });
        alert(message);
    }
}

The server side error message is getting displayed when there is a server side exception, but it still completes the action in UI, i mean it adds the new record to the grid and update as well even though there is server side exception.

Is there any way to retain the state of UI before the action start?, it supposed to work in that way, not sure if i am missing anything?

Thanks in advance

Pat
Top achievements
Rank 1
 answered on 19 Dec 2012
2 answers
313 views

Using version 2012.3.1114.

This work using Visual Studio Development Server but does not show the drop down using IIS Express or IIS 7 on Windows Server 2008 R2
Code in view:

@(Html.Kendo().ComboBoxFor(m => m.ForPost)
      .Filter(FilterType.StartsWith)
      .DataTextField("label")
      .DataValueField("value")
      .MinLength(1)
      .DataSource(source => {
          source.ServerFiltering();
          source.Read(read => {
              read.Action("AjaxPost", "Home"); //Set the Action and Controller name
              read.Type(HttpVerbs.Post);
          });
      }))
Code in Controller:

 

[HttpPost]
public ActionResult AjaxPost(string text) {
    if (string.IsNullOrWhiteSpace(text)) return Json(null);
    var x = Data.Where(d => d.StartsWith(text, StringComparison.InvariantCultureIgnoreCase))
        .Select(d => new { label = d, value = d }).ToList();
    return Json(x);
}

IE 9 in Javascript debug it shows this error "Microsoft JScript runtime error: Unable to get value of the property 'Errors': object is null or undefined" and pints the this dynamic code.

function anonymous(d) {
return d.Errors
}

Using get works fine but our security people insist we use post for ajax.

Thanks,

Tom Wilkinson

 

Georgi Krustev
Telerik team
 answered on 19 Dec 2012
3 answers
1.1K+ views
Hi all

I am currently trying to find a way to automatically set the width of dropdownlist depending on drop down items

Thanks

Jing
Dimo
Telerik team
 answered on 19 Dec 2012
4 answers
217 views
Hi

I have upgraded my kendo application from 2012.2.710  to 2012.3.1114. In the updated dll, when i do ajax binding , the non nullable properties of the model is throwing error but the same was working fine in the '2012.2.710' version. What went wrong in the new version ? please give me a proper solution for this issue. The code to bind the grid is given below.

@(Html.Kendo().Grid<LinklistRow>()
        .Name("Grid").Selectable()
                     .ToolBar(commands => commands.Create().HtmlAttributes(new { Title = "Add New Link" }))                
                .Columns(columns =>
                {
                    columns.Bound(client => client.lkLinkId).Hidden();
                    columns.Bound(client => client.lkTitle).Title("Title").Width(200).Sortable(true);
                    columns.Bound(client => client.lkUrl).Title("Url").Width(500).Sortable(true);
                    columns.Command(commands =>
                    {
                        commands.Edit().Text(" ").UpdateText(" ").CancelText(" ").HtmlAttributes(new { Title = "Edit" });
                        commands.Destroy().Text(" ").HtmlAttributes(new { Title = "Delete" }); ;
                    }).Width(90).HtmlAttributes(new { @class = "k-gridButtonAlignment" });
                }).Editable(editable => editable.Mode(GridEditMode.InLine))
                .Events(e => e.Edit("OnEdit"))
                    .DataSource(dataSource => dataSource.Ajax()
                    .ServerOperation(false)                        
                    .Read(read => read.Action("Show", "Home", new { area = "Link", clientId = Model.ClientId }))
                    .Model(model => model.Id(c => c.lkLinkId))
                    .Create("Create", "Home", new { area = "Link", clientId = Model.ClientId })
                    .Update("Edit", "Home", new { area = "Link", clientId = Model.ClientId })
                            .Destroy("Destroy", "Home", new { area = "Link", clientId = Model.ClientId })
                            .PageSize(20)
                            ).Pageable(pager => pager.PageSizes(true)).Sortable()
                    )

Thanks
Prashanth.
Vladimir Iliev
Telerik team
 answered on 19 Dec 2012
1 answer
575 views
Hi,

I have a little issue, i'm explaining :

I'm working with Kendo and Google Map API and some data are retrieve from the API, like address, postal code, city, country, etc...
I would like to populate different ComboBoxes (Address combobox, Postal Code combobox, etc...)

The problem is that i don't know how to retrieve the selected value from a combobox, any idea please ?

Here is my code :

On Controller (which populate countries combobox) :

public JsonResult GetCascadeCountries()
{
   return Json(_db.Countries.Select(c => new {CountryId = c.Id, CountryName = c.CountryName }), JsonRequestBehavior.AllowGet);
}

Index.cshtml : 

 @(Html.Kendo().ComboBox()
           .Name("Countries")
           .Placeholder("Select a country")
           .DataTextField("CountryName")
           .DataValueField("CountryId")
           .DataSource(source => {
           	source.Read(read => {
                    read.Action("GetCascadeCountries""Index");
                });
           })
   )

In the javascript file :

if (elt.types[0] == 'country')
    {
        var countriesComboBox = $('#Countries').data("kendoComboBox");
        alert($('#Countries_input').data());
        var selectItem = function (dataItem) {
            //dataItem argument is a ComboBox data item.
            return dataItem.Text == elt.long_name;
        }
 
        countriesComboBox.select(selectItem);
    }

I tried with a document.getElementsByName ou document.getElementById, to set the value, but i still fail :/

Any idea ?

Thanks

Edit : I've found, you have to set the trigger manually : countriesComboBox.trigger("change");
Petur Subev
Telerik team
 answered on 19 Dec 2012
1 answer
211 views
Hello.
I just updated to Kendo UI for ASP.NET MVC Q3 2012 and I am trying to create a pageable, filterable, sortable and groupable grid. We are using ASP.NET MVC, but because of the MVVC architecture we are using, the grid properties are being defined using html attributes, like this:

<div id="userGrid"
  data-role="grid"
  data-columns='[{ "field": "Name", "title": "Name"}, { "field": "Group", "title": "Group"}]'
  data-filterable='true'
  data-navigatable='true'
  data-pageable='true'
  data-groupable='true'
  data-sortable='true'
  data-bind="source: userDataSource"></div>
and the DataSource is being set in javascript like this:

userDataSource: new kendo.data.DataSource({
type: "aspnetmvc-ajax",
transport: {
read: {
url: '/home/ListUsers'
}
},
schema: {
model: {
id: 'ID',
fields: {
ID: {
type: 'number'
},
Name: {
type: 'string'
},
Group: {
type: 'string'
}
}
},
data: 'Data',
total: 'Total'
},
page: 1,
pageSize: 30,
serverPaging: true,
serverSorting: true,
serverFiltering: true,
serverAggregates: true,
serverGrouping: true
})

The ListUsers actions simply returns the corresponding data using DataSourceRequest, like this:

public ActionResult ListUsers([DataSourceRequestDataSourceRequest request)
{
  return Json(GetUsers().ToDataSourceResult(request));
}


By doing this, the grid is shown correctly, the paging, filtering and sorting all work fine, but not the grouping. I can see the column "drop area" and I can drag the column headers, but I can't drop them.
I compared the grid properties with the script generated when using the MVC wrapper (using the wrapper, the grouping works) and I didn't see anything different that could be related to grouping. Am I missing something?

Thanks!
Nikolay Rusev
Telerik team
 answered on 19 Dec 2012
1 answer
1.1K+ views
Hello, I am trying to create a reusable control (partial view) utilizing the Kendo UI Autocomplete widget. The issue is that since this new partial I am creating can appear multiple times in a view, how can you pass in or otherwise use a variable as the .Name() attribute in the AutoComplete helper?

Here is my partial view:
@using Kendo.Mvc.UI;
@model IEnumerable<OTIS.AppServ.Shared.ViewModels.ddlOptions>
 
@(Html.Kendo().AutoComplete()
    .Name("TEST")
    .Filter("startswith")
    .DataTextField("DisplayName")
    .BindTo(Model)
    .Events(e => e
        .Change("autocomplete_change")
    )
    .Placeholder("Select Customer...")
    .HtmlAttributes(new {@class = "filter"}) 
)
<input class="filter" id="@ViewBag.ControlId" type="hidden" />
<script>
    //$("#TEST").attr("id", '@ViewBag.ControlId' + '_org');
 
    function autocomplete_change() {
        var hiddenInput = $('#' + '@ViewBag.ControlId');
        var autoContainer = $("#" + 'TEST').data("kendoAutoComplete");
        var result = $.grep(autoContainer.dataSource.data(),
                                function (itemInArray, itemIndex) {
                                    return itemInArray.DisplayName == autoContainer.value();
                                }
                            );
        //alert(result[0].Id)
        hiddenInput.val(result[0].Id);
    }
</script>

My controller will handle acquiring the specific data and then passing it to the partial (it needs to take a parameter to populate ViewBag.ControlId, for now it is just hard coded):

[ChildActionOnly]
        public ActionResult Customers()
        {
            List<ddlOptions> viewModel = new List<ddlOptions>();
            viewModel = _manageDDLsAppServ.GetCustomersDDLViewModel(_currentCompanyId).ToList();
            ViewBag.ControlId = "customerIdFilter";
 
            return PartialView("_ddlOptionsAutoComplete", viewModel);
        }
I then call this partial from my view like:
@{ Html.RenderAction("Customers", "ManageDDLs", new { area = "Shared" }); }

 I tried JQuery, to change the name at run time, but this then breaks the Kendo jquery script as it will be looking for the original name.
Chad
Top achievements
Rank 1
 answered on 19 Dec 2012
1 answer
565 views
Per the documentation I am trying to add Events to the autocomplete helper so I can lookup the value of the selected item (as seen in this post), but when doing so am getting the following error on line 10:
Compilation Error
 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
 
Compiler Error Message: CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
 
Source Error:
 
 
Line 8:      .DataTextField("DisplayName")
Line 9:      .BindTo(Model)
Line 10:     .Events(e => e
.Change("autocomplete_change"))
Line 11:     .Placeholder("Select Customer...")
Line 12:     .HtmlAttributes(new {@class = "filter"})
Here is the PartialView 
@using Kendo.Mvc.UI;
@model IEnumerable<OTIS.AppServ.Shared.ViewModels.ddlOptions>
 
 
@(Html.Kendo().AutoComplete()
    .Name(ViewBag.ControlId)
    .Filter("startswith")
    .DataTextField("DisplayName")
    .BindTo(Model)
    .Events(e => e
.Change("autocomplete_change"))
    .Placeholder("Select Customer...")
    .HtmlAttributes(new {@class = "filter"})
     
)
<script>
    function autocomplete_change() {
        var autoContainer = $("#AutocompleteId").data("kendoAutoComplete");
        var result = $.grep(autoContainer.dataSource.data(), function (item) {
        item.Text == autoContainer.value();
        });
    }  
 
</script>
Call from View:
@{ Html.RenderAction("Customers", "ManageDDLs", new { area = "Shared" }); }
Controller:
[ChildActionOnly]
        public ActionResult Customers()
        {
            List<ddlOptions> viewModel = new List<ddlOptions>();
            viewModel = _manageDDLsAppServ.GetCustomersDDLViewModel(_currentCompanyId).ToList();
            ViewBag.ControlId = "customerIdFilter";
 
            return PartialView("_ddlOptionsAutoComplete", viewModel);
        }

Chad
Top achievements
Rank 1
 answered on 18 Dec 2012
1 answer
6.3K+ views
I have a page with a grid and beneath it, a tab.  I want to change the header column colors.

That grid is declared within a td at the top of the page.  I declared a style within that td, setting .k-header to my new color and that grid does reflect that new color.

But now everything else below, even outside that td, also now has the new color, even the tab.  When I open the modal window on that page, even the window is now using the new color.

I thought styles changes were local to the element they are in?  If so, then why is this happening?  If not, then what is the correct way to target a specific color to one specific grid?
Pat
Top achievements
Rank 1
 answered on 18 Dec 2012
2 answers
171 views
Hi, 

I am working on a 500 000 rows grid, that is why I have used the virtualization of remote data. 
There is a bug though, which happens only with chrome (i.e. not with firefox and IE 9, whaaaaaaat !!).

I have made a fiddle to recreate this bug, using the kendo remote data demo.

To see the bug, do the following steps: 
1) put the scroll in the bottom of the grid
2) use the mousse wheel to go up until you see the load-image.gif
3) then, go back in the bottom with the mousse wheel, you'll see a number of data different than 11077 (which is the good one);

if the bug does not appears, do it again a few times. 

Do you have an idea of where does this come from ? 
Is there something wrong in my code ? 

here is the fiddle link: http://jsfiddle.net/johnjohn/mqPxH/1/
martin
Top achievements
Rank 1
 answered on 18 Dec 2012
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
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
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?