Telerik Forums
Kendo UI for jQuery Forum
0 answers
100 views

Hi,

i fill a grid step by step with many data from a database.

on load the grid is empty. an javascript fills the grid with a result of an ajax-request.

while he is loading the items every "tick" of inserting new items to the datasource, the grid lost the user-written text in the filters, so the user have to rewrite it.

you also lost the selecection of an row.

it looks like the grid will be rebuild in the DOM every time i add an item.

is there any mechanic to prevent this?

thats my grid:

@(Html.Kendo().Grid<Object>().Name("KomplettabbzuegeGrid")
    .ToolBar(toolBar => toolBar.Custom()
                               .Text("<i class='icon-download'></i>Exportieren")
                               .HtmlAttributes(new { id = "export" })
                               .Url(Url.Action("Export", "Vorbereitung", new { page = 1, pageSize = "~", filter = "~", sort = "~", initGruppenId = ViewBag.CurrKompfGrp }))
            )
    .Columns(columns =>
    {
        columns.Bound("Vfnr").Title("VFNR").Filterable(true);
        columns.Bound("Betriebsname").Title("Betrieb").Filterable(true);
        columns.Bound("Ort").Title("Ort").Filterable(true);
        columns.Bound("HochgeladenAmDatum").Format("{0:dd.MM.yyyy hh:mm}").Title("Hochgeladen am").Filterable(false);
        columns.Bound("Status").Title("Status")
            .ClientTemplate("#= (Status == 2 ? 'offen': " +
                            "(Status == 3 ? 'akzeptiert':" +
                            "(Status == 4 ? 'abgelehnt': 'unbekannt'" +
                            "))) #")
                            .Filterable(false);
        columns.Bound("Terminstellung").Title("Terminstellung")
            .ClientTemplate("#= (Terminstellung == 'A' ? 'Welle 1': " +
                            "(Terminstellung == 'B' ? 'Welle 2':" +
                            "(Terminstellung == 'C' ? 'Welle 3': 'unbekannt'" +
                            "))) #")
                            .Filterable(false);
    })
    .Sortable(x => x.Enabled(true))
    .Pageable(x => x.Enabled(true))
    .Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
        .Events(c => c.DataBound("function (e) {CollapseAllRows('#KomplettabbzuegeGrid');}").DataBound("onDataBound"))
    .Filterable()
    .Resizable(c => c.Columns(true))
    .Groupable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .ServerOperation(false)
        .Sort(sort => sort.Add("HochgeladenAmDatum").Descending())
           ))

and thas the javascript wich adds the lines:

function loadGridData(gridDataSource, url, data)
{
    if(typeof data['skip'] === "undefined" || typeof data['take']  === "undefined")
        return;
     
        if(grpId != data["initGruppenId"]) {
            return;
        }
    $.ajax(
    {
        type: 'POST',
        url: url,
        dataType: 'json',
        data: data,
        success: function (result)
                 {
                    if(grpId != data["initGruppenId"])
                        return;
                 
                    if (result.Data == null)
                        return;
             
                    for (var i = 0; i < result.Data.length; i++)
                    {
                        gridDataSource.add(result.Data[i]);
                    }
                    data['skip'] = data['skip'] + data['take'];
                    loadGridData(gridDataSource, url, data);
                 },
        error: function (result)
               {
                   return;
               }
    });
}

Thanks
Dennis
Top achievements
Rank 1
 asked on 23 Nov 2012
0 answers
1.6K+ views
Hello,

I try to combine Kendo UI with Struts 2 action. Until now the results to retrieve data from the DB are satisfactory.
The table is loaded correctly with the data retrieved from the Action.  The problem starts when i try to delete
an entry. 

Source code:

<script>
              $(document).ready(function () {
 
                  var crudServiceBaseUrl = "http://demos.kendoui.com/service",
                      dataSource = new kendo.data.DataSource({
                          transport: {
                              read:  {
                     url: "http://localhost:8080/ProjectRoot/myProject,
                                  dataType: "json"
                              },                         
                              destroy: {
                                  url: "http://localhost:8080/ProjectRoot/myProject!deleteRow",
                                  dataType: "jsonp",
                                  contentType: "application/json; charset=utf-8"
                              },
                              parameterMap: function(options, operation) {
                                  if (operation !== "read" && options.models) {
                                      return {models: kendo.stringify(options.models)};
                                  }
                              }
                          },
                          batch: true,
 
                          pageSize: 30,
                          schema: {
 
                              data: "myList",
                              model: {
                                  id: "uuid",
 
                                  fields: {
                             
                                      uuid: { editable: false, nullable: true },
                                      lang: { type: "string" },
                                      text: { type: "string" }
 
                                  }
                              }
                          }
                      });
 
                  $("#grid").kendoGrid({
                      dataSource: dataSource,
                      pageable: true,
                      height: 400,
                      toolbar: ["create"],
                      columns: [
                          { field:"lang", title: "Language" },
                          { field: "text", title:"Text", width: "150px" },
                          { command: ["edit", "destroy"], title: " ", width: "210px" }],
                      editable: "popup"
                  });
              });
          </script>


Inside my Struts 2 action i have getters and setters for the following variables:
-String text;
-String lang;
-String models;

Now i noticed the following behaviour:

First Scenario

When calling the deleteRow function in my struts action, the following parameters are send of the current row that i want to delete:
callback jQuery17201980517354870166_1353667373995
models [{"lang":"de","text":"ProjectRoot-System","uuid":"c0437761-1c29-11e2-892e-0800200c9a66"},{"lang":"de","text":"Stephan","uuid":"46baf7b1-2345-11e2-81c1-0800200c9a66"}]

This is a copy of the url parameters: _=1353667421178
callback=jQuery17201980517354870166_1353667373995
models=[{"lang":"de","text":"ProjectRoot-System","uuid":"c0437761-1c29-11e2-892e-0800200c9a66"},{"lang":"de","text":"Stephan","uuid":"46baf7b1-2345-11e2-81c1-0800200c9a66"}]

Unfortunately as a response from the server i get the following error :
org.apache.struts2.json.JSONException: Input string is not well formed JSON (invalid char ?)
    org.apache.struts2.json.JSONReader.buildInvalidInputException(JSONReader.java:155)

I did a debugging on the JSONInterceptor and found out that the json variable when trying to do the deserialize
Object obj = JSONUtil.deserialize(request.getReader());
the json variable is an empty string. Thus the above error.


Second Scenario

Instead of calling a function to delete, i changed that to call an action. When doing this, the action
is called and my String models variable is set with the following values [{"lang":"de","text":"ProjectRoot-System","uuid":"c0437761-1c29-11e2-892e-0800200c9a66"}].

This seems sort of correct. Unfortunately with this case, the whole process does not go through the
JSONInterceptor, so no deserialization is happening.



So what is my goal:
To be able when pressing on delete to call the delete function and set the object with the values that are
sent from kendo in order to continue with my own business logic process. What could be wrong
in my first scenario ?

Please let me know if you need further information.

Regards

Stephan



Stephan
Top achievements
Rank 1
 asked on 23 Nov 2012
1 answer
266 views
I used Telerik Components for ASP.NET MVC and recently upgraded to Kendo UI. I must admit it has been a very rough transition due to incomplete documentation and demos that are not nearly as good as those for Telerik Components for ASP.NET MVC. For example, the Grid events documentation does not show how to do anything with the "e" arg passed into the handler.

I am struggling to use the event args or even the "this" passed into my change event handler. I cannot even tell which cell was clicked or whether the actual clicked element was an anchor tag that should show a popup. When I run the code "e.cellIndex()" returns -1. What good is that?

Can someone point me to a tutorial that helped them use the change event? Thanks.
Petur Subev
Telerik team
 answered on 23 Nov 2012
5 answers
129 views
Hi,

I understand that this framework targets Android, iOS and Blackberry but I was hoping that my application will somewhat still work on a Windows Phone. Running it this morning on a Windows Phone 7.5 was shocking.

Is this the norm, should I expect the application not to work at all on a Windows Phone browser or is there something I am doing wrong?

Is there a way for me to target a different layout for Windows Phone or is this framework just not able to work on this platform?

I guess if this is the case I would rather abandon the framework and just code a general interface that will work on all devices.

Thanks,
Anton
Petyo
Telerik team
 answered on 23 Nov 2012
0 answers
93 views
I have a question..
with kendo i can do this:
for example in a pie chart when i click on one part of this, then show me another chart.?
David
Top achievements
Rank 1
 asked on 22 Nov 2012
1 answer
126 views
Hi! - Please check your demo NumberTextBox/ Basic Usage with Metro style by clicking the spinner. Colors at the border and background are not visible.
Dimo
Telerik team
 answered on 22 Nov 2012
2 answers
413 views
I have an issue where I have defined and created my KendoUI Web Grid widget in javascript and am attempting to perform batch editing.  I have followed all of the examples I can find, but when the "update" action executes on the controller, it fails to bind the data.  

I have the following:
A Contact Model:
public class ContactModel
      {
      public int Id { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public string GenderCode { get; set; }
      public DateTime BirthDate { get; set; }
      public AddressModel Address { get; set; }
      public string Email { get; set; }
      public string Phone { get; set; }
      public decimal DesiredSalary { get; set; }
      }
A Controller Action defined to Update:
[AcceptVerbs(HttpVerbs.Post)]
     public ActionResult _UpdateGridData([DataSourceRequest] DataSourceRequest request, [Bind(Prefix="models")]IEnumerable<Models.ContactModel> models)
         {
                 if (models != null && ModelState.IsValid)
             {
             foreach (var contact in models)
                 {
                 var target = model.Values.Where(x => x.Id == contact.Id).FirstOrDefault();
                 if (target != null)
                     {
                     target.LastName = contact.LastName;
                     target.FirstName = contact.FirstName;
                     target.BirthDate = contact.BirthDate;
                     target.GenderCode = contact.GenderCode;
                     }
                 }
             }
         return Json(ModelState.ToDataSourceResult());
         }
And my Grid is configured in JavaScript:
// Create a Datasource.
var gridDataSource = new kendo.data.DataSource({
    dataType: "json",
    data: "Data",
    transport: {
        read: {
            url: '@Url.Action("_GetGridData", "KendoGrid")',
            dataType: "json"
        },
        update: {
            url: '@Url.Action("_UpdateGridData", "KendoGrid")',
            dataType: "json",
            type: "POST"
        }
    },
    pageSize: 10,
    batch: true,
    schema: {
        model: {
            id: "Id",
            fields: {
                Id: { type: "number", editable: false, nullable: true },
                FirstName: { type: "string", validation: { required: true } },
                LastName: { type: "string", validation: { required: true } },
                GenderCode: { type: "string", nullable: true },
                BirthDate: { type: "date" }
            }
        }
    }
});
 
// Create a Grid using the above data source.
$("#inlinekendogrid").kendoGrid({
    columns: [
        { field: "Id", title: "ID", width: 8, filterable: false, editable: false },
        { field: "FirstName", title: "First Name", width: 25 },
        { field: "LastName", title: "Last Name", width: 25 },
        { field: "GenderCode", title: "Gender", width: 25 },
        { field: "BirthDate", title: "Born", width: 25, format: "{0:MM/dd/yyyy}" }
    ],
    editable: {
        create: true,
        update: true,
        destroy: true,
        confirmation: "Are you sure you wish to remove this entry?"
    },
    dataSource: gridDataSource,
    sortable: {
        mode: "multiple"
    },
    pageable: {
        refresh: true,
        pageSizes: true
    },
    selectable: true,
    navigatable: true,
    filterable: true
 
});
Everything seems to work fine except for it doesn't get bound to my ContactModel.  The data coming up from the form is as follows:
Form Dataview URL encoded
models[0][Id]:2
models[0][FirstName]:Sally
models[0][LastName]:Shoreman22
models[0][GenderCode]:F
models[0][BirthDate]:Mon Sep 20 2010 00:00:00 GMT-0700 (Pacific Daylight Time)
models[0][Address][AddressLine1]:2 Way Street
models[0][Address][AddressLine2]:
models[0][Address][AddressLine3]:
models[0][Address][City]:Salem
models[0][Address][State]:OR
models[0][Address][ZipCode]:97312
models[0][Email]:salshor@saif.com
models[0][Phone]:
models[0][DesiredSalary]:0

I have not found any examples of people using Web Grid Widget in javascript with an MVC Controller.  Is the mixing of the two what is causing my troubles?  Do I need to configure the DataSource differently?  Any help would be appreciated.

Richard Wilde
Top achievements
Rank 1
 answered on 22 Nov 2012
0 answers
112 views
Hi,

How do I hide the "Index" button that tabstrip shows at the buttom.

Very often the tab stop working after I click the Index button, the tab is not selected the blue line under icon just flashes once.

I'm using KendoUI with Cordova / Android.

Kennet
Top achievements
Rank 2
 asked on 22 Nov 2012
2 answers
202 views
See doc here:
http://docs.kendoui.com/getting-started/web/upload/metadata#receiving-metadata-from-the-save-handler

What does the example code listed in this section of the doc have to do with receiving the metadata???  ...seems like you pasted the wrong example.  How about showing us how to receive the metadata.  I'm guessing it will be in the querystring?

Thanks.
Roopa
Top achievements
Rank 1
 answered on 22 Nov 2012
3 answers
680 views
I'm trying to upload a file to a document in CouchDB.
To do so, I need to provide the document identifier as part of the url AND a revision as an additional field. This is not a problem if I'm submitting a form with both inputs (revision and file) but I wonder if it is possible with asynchronous upload do something similar. Is it? How? 
Daniel Probst
Top achievements
Rank 1
 answered on 22 Nov 2012
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Drag and Drop
Application
Map
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
PivotGridV2
Licensing
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?