Telerik Forums
UI for ASP.NET MVC Forum
2 answers
383 views
Hi all,

I have been browsing the forums and stack overflow and can't find a solution to this.

I implemented the generic Kendo "error" js method as shown in the demos in order to show errors on updates, and then I added the error to my modelstate.

When the grid tries to update and an error is thrown - it automatically retries up to 4 time. Is there a way to prevent this retry from happening?

I am using MVC4 - and a standard MVC controller.

Here is my controller error handler:

catch (Exception ex)
            {
                ModelState.AddModelError("Error", ex.Message);               
                return Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet);
            }


Here is the js code for showing the error:

function error(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 grid uses a standard Async update method in order to perform the update, and this goes to an MVC controller and not an API controller.

My question again: When the grid tries to update and an error is thrown - it automatically retries up to 4 time. Is there a way to prevent this retry from happening?
Quentin
Top achievements
Rank 1
 answered on 05 Jun 2013
1 answer
118 views
Hi,

I am using the image browser to upload relatively small images (ie 500k) to the filesystem. I have a process whereby the file is uploaded, the MVC controller saves this image to a particular place with a particular name (a GUID). It then returns the JSON result with the new name of the image. This process works perfectly on a local development machine. However, when I deployed this to our test environment, the image was uploaded, but the thumbnail stayed on the swirling ajax loading image.

I've since found that by debugging on my development machine (and therefore slowing down the process) that the ThumbnailUrl gets called before the image has finished uploading. It also gets called with the original name of the file, which is obviously no good for me, as I have changed the name of the file during saving. When this process happens in quicker succession on my local machine, everything gets called at the right time, with the right parameters.

Is there anyway to delay the call to the thumbnailurl call to ensure the upload has completed? Currently I'm having to close the image browser window and reopen so that it loads the thumbnails correctly.

Thanks
Rosen
Telerik team
 answered on 05 Jun 2013
1 answer
220 views
I'm really new at KendoUI.  Just learning it in fact.

I just got this exception (see title) and I really don't know what it means, or why I can't do it.
I'm using an MVC 4 framework in VS 2012

So... some questions.
I know what virtual scrolling is, What is Server binding?
How do I know if I'm doing Server binding?
Is there a way to work around this?Thanks
Robert
Atanas Korchev
Telerik team
 answered on 05 Jun 2013
2 answers
303 views
I need to reset to the first page after sorting the grid. I was trying to use the change event like i was doing when changing page which works perfectly here is my example on how I keep track of my paging.
   var pageable = false;
          if (self.Pageable == true)
              pageable = {
                  refresh: false,
                  pageSizes: self.PageSizes,
                  change: function(e) {
                      if (typeof (Storage) !== "undefined") {
                          localStorage.setItem(self.PageStorageVariable, self.Grid().dataSource.page());
                      }
                  }
              };

and then apply pageable variable to my grid definition
   var g = {
              scrollable: false,
              pageable : pageable ,
              ...
  }

Every time I change a page it gets stored in my local storage and then I do some stuff with it.

I need the same functionality for sorting but only on the on change event:

  var sortable = false;
          if (self.Sortable == true)
              sortable = {
                  mode: "single",
                  allowUnsort: true,
                  change: function (e) {
                      console.log('here');
                  }
              };

          var g = {
              scrollable: false,
              pageable : pageable ,
              sortable : sortable,
             ...
         };

But in this case every time I apply a new sort its not firing my on change function, any ideas on how can I intercept the onSort event so I can reset to page 1 when sorting?
Tim Eck
Top achievements
Rank 1
 answered on 04 Jun 2013
0 answers
83 views
I'm really new at KendoUI.  Just learning it in fact.

I just got this exception (see title) and I really don't know what it means, or why I can't do it.
I'm using an MVC 4 framework in VS 2012

So... some questions.
  1. I know what virtual scrolling is, What is Server binding?
  2. How do I know if I'm doing Server binding?
  3. Is there a way to work around this?
Thanks
Robert
Robert
Top achievements
Rank 1
 asked on 04 Jun 2013
8 answers
607 views
Hello,i did the example with listview editing and it's ok.But if i have also a foreign key to category for example,how cand i use a dropdown list filled with the categories,in that template that appear when i press edit button?
in razor if possible.

Thanks in advance
Daniel
Telerik team
 answered on 04 Jun 2013
1 answer
240 views
I am developing an MVC 4 website for a customer and have run into an issue with the dropdownlist. 

I have a Grid, bound to my model, and I can see all the data (correctly) in the grid.
01.@(Html.Kendo().Grid((IEnumerable<MyModel>)ViewBag.Model)
02.                    .Name("Grid")
03.                    .Columns(columns =>
04.                    {
05.                        ..
06.                        removed for brevity
07.                        ..
08.                        columns.Command(command => { command.Edit(); command.Destroy(); });
09.                    })
10.                    .ToolBar(toolbar => toolbar.Create())
11.                    .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("EditorTemplate"))
12.                    .Pageable()
13.                    .Sortable()
14.                    .Scrollable()
15.                    .DataSource(dataSource => dataSource
16.                        .Ajax()
17.                        .PageSize(20)
18.                        .Events(events => events.Error("error_handler"))
19.                        .Model(model => model.Id(m => m.recordID))
20.                        .Create(update => update.Action("Create", "Controller"))
21.                        .Update(update => update.Action("Update", "Controller"))
22.                        .Destroy(update => update.Action("Destroy", "Controller"))
23.                    )
24.                )
The above code loads the grid fine, I can trigger all the actions correctly, and they all work great.

My problem comes in when I edit a row, and the field I need to change is a DropDownList. For this particular issue, it is a list of States. We are using popup edit mode, and have a custom editor template.

This is the Editor Template code.
01.@(Html.Kendo().DropDownListFor(m => m.StateId)
02.        .Name("StateId")
03.        .DataTextField("StateName")
04.        .DataValueField("StateId")
05.        .DataSource(source =>
06.        {
07.            source.Read(read =>
08.            {
09.                read.Action("GetStatesList", "Controller");
10.            })
11.            .ServerFiltering(true);
12.        })
13.        .SelectedIndex(0)
14.        .OptionLabel("Select a State")
15.    )
The control successfully loads the states, and binds to the model, and shows the correct state value, if there is one provided. In our database, the StateId field is Nullable, and I think this is where the problems arise. 

For completeness, here is the controller function that populates the state list.
1.public JsonResult GetStatesList()
2.{
3.    var states = client.GetStates();
4.    return Json(states, JsonRequestBehavior.AllowGet);
5.}
the client.GetStates() returns an IEnumerable<State> collection.

NOTE: This exact same code works in a non-grid view in our MVC project.

Now, when the StateId is populated on load, it will display the correct state in the DropDownList. If I change this state and click the Update button on my popup editor, the Update Action is triggered, model.StateId = NewIDSelected and the change gets saved to the database. Now if the StateId is NULL from the database, obviously no state is selected, but now, if I select a state from the DropDownList, and click the Update button on my editor, the Update Action is not triggered, and no change is saved to the database.

To add to that, if I change any other field on the editor (say change or add the street address)  in addition to the State change (from null to a state value), the Update Action is correctly triggered, but the model.StateId = null.

As I stated before, this exact same scenario works perfectly on a view that does not use a grid at all (as a matter of fact the popup editor is an exact duplicate of that view).

Can anyone help me figure out how to fix this? We have got around it by using a plain HTML DropDownList, but it is ugly ugly... but it works.
Daniel
Telerik team
 answered on 03 Jun 2013
2 answers
108 views
The dropdownlist does not seem to find a value when I have a repeating character.

For example, I'm looking for a last name of "Allen".  I start typing "al" and the first occurrence with of a name beginning with "Al" is highlighted.  When I type the next "l", it jumps to the first occurrence of a name that begins with "L".

A regular html dropdownlist does not seem to behave this way.

I've tried fiddling with the delay option but it doesn't seem to help.

thanks
William Dunn
Top achievements
Rank 1
 answered on 03 Jun 2013
3 answers
254 views
I have grid with client detail template:

@(Html.Kendo().Grid<SalesOrderModel>()
      .Name("SalesOrders")
      .Columns(columns =>
          {
              columns.Bound(e => e.Number).Width(20).ClientTemplate(Html.ActionLink("#=Number#", "Edit", "SalesOrder", new { id = "#=Id#" }, null).ToHtmlString());
              columns.Bound(e => e.Status).Width(20);
              columns.Bound(e => e.ContractorName).Width(200);
              columns.Bound(e => e.CreatedDate).Width(40).Format("{0:d}");
          })            
      .ClientDetailTemplateId("itemsTemplate")
      .Pageable()
      .DataSource(dataSource => dataSource
                                    .Ajax()
                                    .Read(read => read.Action("LoadData", "SalesOrder"))
                                    .PageSize(40)
      )
      .Sortable()
      .Filterable())
<script id="itemsTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<SalesOrderItem>()
            .Name("Items_#=Id#")
            .Columns(columns =>
            {
                columns.Bound(o => o.Position).Width(20);
                columns.Bound(o => o.Index).Width(100);
                columns.Bound(o => o.Name).Width(200);
                columns.Bound(o => o.Quantity).Width(20);
                columns.Bound(e => e.UnitOfMeasure).Width(20);
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("LoadItems", "SalesOrder", new { salesOrderId = "#=Id#" }))
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
    )
</script>

and everything worked perfectly until now. I changed globalization section in web.config from
<globalization enableClientBasedCulture="true" culture="auto" /> 
to 
<globalization enableClientBasedCulture="false" culture="pl-PL" uiCulture="pl-PL" />
After this change exception is throwing by javascript "Invalid template ..."
Note that everything woks good except master-detail grid described above.

2Trace
Top achievements
Rank 1
 answered on 03 Jun 2013
2 answers
412 views
i was looking here
http://docs.kendoui.com/api/web/tooltip
after some posibilities to customize the tootip,but i did not find.
i would like to setup the dimensions of the container where is the text,also the color,and maybe the position or even the form of that poiting arrow.i noticed that by default is a gray color,and a perfect triangle as an arrow.

How can i customize the style for the tooltip?

Regards,
Daniel
Daniel
Top achievements
Rank 1
 answered on 03 Jun 2013
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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Security
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
SegmentedControl
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?