Telerik Forums
Kendo UI for jQuery Forum
5 answers
450 views
Every sample I can find works on the premise of multiple rows of data coming back.

In our case there is only one row being returned because this is a single item edit screen.

I have a Web API request that returns an object. Here's the response from the call:

{
  "FirstName": "James",
  "LastOrCompanyName": "Hancock",
  "MiddleName": "Robert",
  "Salutation": "Mr.",
  "Suffix": null,
  "Individual": true,
 <...more fields...>
}

It's formatted exactly like that with Json.

What I'm attempting to do is put text boxes that allow edit of those values.

Here's what I have:

var Contact = kendo.data.Model.define({
        ID: "ID"
    });


    dataSource = new kendo.data.DataSource({
        type: "json", // specifies data protocol
        transport: {
            read: { url: "/api/v1/contacts/GetContactByID?id=" + ContactID },
        },
        schema: {
            model: {
                    id: "ID"
            }
        },
        change: function (e) {
            selectedContact = e;
        },
        error: function (e) {
            debugger;
        }
    });

    var viewModel = kendo.observable({
        dataSource: dataSource,
        hasChanges: false,
        change: function () {
            this.set("hasChanges", true);
        }
    });


    kendo.bind($("#contact-info"), viewModel);


for sake of argument I also bound a grid to the datasource like so:

    $("#g-contact-info").kendoGrid({
        groupable: true,
        scrollable: { virtual: true },
        sortable: true,
        pageable: true,
        dataSource: dataSource
    });

The grid doesn't display any data even though one item came back.

And I can't figure out any way to logically set the observable to the first item even if it did. I was expecting some sort of data control on the observable that allowed you to change which is the current item just like a BindingSource in Winforms or something.

Can someone help with the two issues? First being the data not coming back and binding properly, the second being how do I get the observable to set properly and get my selectedContact set with the right value.

Thanks!
Gareth
Top achievements
Rank 1
 answered on 25 Jun 2012
3 answers
981 views
Hi ,
I am developing an application using kendoui grid,and i am facing a problem
when grouping the records according  to different columns.
I want to have records grouped by name column and at the same time have footerTemplate and groupFooterTemplate for quantity  column.
When i add another column on grouping i get an error 'sum is not defined'.
I have looked around on kendo forums, and even the following forum topic:
http://www.kendoui.com/forums/ui/grid/groupable-aggregates-and-groupfootertemplate-problems.aspx

doesn't resolve me the problem.(which looks me more similar to my problem).
I am putting the columns,group,aggregates and fields using php variables:
$arr=array(array('field'=>'pol','title'=>'Part Number','width'=>'200px','aggregates'=> "count", 'groupHeaderTemplate'=> "Part Number: #=value#"),
     array('field'=>'name','title'=>'PO ','aggregates'=> "count", 'groupHeaderTemplate'=> "PO Teknema: #=value#"),
     array('field'=>'po_supp','title'=>'PO Supplier','aggregates'=> "count", 'groupHeaderTemplate'=> "PO Supplier: #=value#"),
     array('field'=>'seltc','title'=>'Quantity Received','aggregates'=> "count", 'groupHeaderTemplate'=> "Quantity Received: #=value#"),
     array('field'=>'pol_qty','title'=>'Qty to Receive','aggregates'=> "sum", 'footerTemplate'=> "Total Sum: #=sum#",'groupFooterTemplate'=> "Sum: #=sum#" ),
     array('field'=>'qty_purchased','title'=>'Total Qty','aggregates'=> "count", 'groupHeaderTemplate'=> "Total Qty: #=value#"),
     //array('field'=>'prod_name','title'=>'Part Number'),
     array('field'=>'rif_ordine','title'=>'Rif.Ordine','aggregates'=> "count", 'groupHeaderTemplate'=> "Rif.Ordine: #=value#"),
     array('field'=>'project','title'=>'Project','aggregates'=> "count", 'groupHeaderTemplate'=> "Project: #=value#"),
     array('field'=>'po_ref','title'=>'PO Reference','aggregates'=> "count", 'groupHeaderTemplate'=> "PO Reference: #=value#"),
  );
$columns=json_encode($arr);
$arr=array(
    'pol'=>array('type'=>'string'),
    'name'=>array('type'=>'string'),
    'po_supp'=>array('type'=>'string'),
    'seltc'=>array('type'=>'string'),
    'pol_qty'=>array('type'=>'number'),
    'qty_purchased'=>array('type'=>'number'),
    //'prod_name'=>array('type'=>'string'),
    'rif_ordine'=>array('type'=>'string'),
    'project'=>array('type'=>'string'),
    'po_ref'=>array('type'=>'string'),
     );
$fields=json_encode($arr);
$arr=array('field'=>'name',
    'aggregates'=>array(
        array('field'=>'pol','aggregate'=>'count'),
        array('field'=>'name','aggregate'=>'count'),
        array('field'=>'po_supp','aggregate'=>'count'),
        array('field'=>'seltc','aggregate'=>'count'),
        array('field'=>'pol_qty','aggregate'=>'sum'),
        array('field'=>'qty_purchased','aggregate'=>'count'),
        array('field'=>'rif_ordine','aggregate'=>'count'),
        array('field'=>'project','aggregate'=>'count'),
        array('field'=>'po_ref','aggregate'=>'count'),
        )
        );
$group=json_encode($arr);
$arr=array(
    array('field'=>'pol','aggregate'=>'count'),
    array('field'=>'po_supp','aggregate'=>'count'),
    array('field'=>'seltc','aggregate'=>'count'),
    array('field'=>'pol_qty','aggregate'=>'sum'),
    array('field'=>'qty_purchased','aggregate'=>'count'),
    array('field'=>'rif_ordine','aggregate'=>'count'),
    array('field'=>'project','aggregate'=>'count'),
    array('field'=>'po_ref','aggregate'=>'count'),
     );
$aggregate=json_encode($arr);

and then pass these variables on js 


Please Help me to solve the problem.
Thanks in advance
Atanas Korchev
Telerik team
 answered on 25 Jun 2012
1 answer
189 views
We need uniform implementation and dedicated documentation similar to "Configuration" that describes how to declaratively bind controls.  I'm having to do a lot of repetitive coding for binding that should be a simple declarative structure.  You should be able to enable a property on your kendo framework and request it to declaratively data bind and off you go.  Very little coding necessary.  For example:

<input id="siteList" class="ctrlDropDown" data-template="#siteListTemplate" data-dataurl="Layout/sites.json" data-selector="sites" /> 

    $(".ctrlDropDown")
    .each(function (index, htmlControl) {
        var control = $(htmlControl);
        var dataSourceUrl = control.attr("data-dataurl");
        //alert(dataSourceUrl);
        var dataSourceCallback = control.attr("data-datacallback");
        var template = control.attr("data-template");
        var dataType = control.attr("data-type");
        var dataText = control.attr("data-text");
        var dataValue = control.attr("data-value");
        var dataSelector = control.attr("data-selector");
        //alert(dataSelector);
        var dataSource = new kendo.data.DataSource({
            type: (dataType != null) ? dataType : null,
            transport: {
                read: {
                    url: dataSourceUrl,
                    jsonpCallback: (dataSourceCallback != null) ? dataSourceCallback : ""
                }
            }
        });
        dataSource.fetch(function (data) {
            //alert(JSON.stringify(data.sender._pristine));
            control.kendoDropDownList({
                autoBind: true,
                dataTextField: dataText,
                dataValueField: (dataValue != null) ? dataValue : dataText,
                template: (template != null) ? kendo.template($(template).html()) : null,
                dataSource: (dataSelector != null) ? eval("data.sender._pristine." + dataSelector) : data.sender._pristine
            });
        });
    });
Atanas Korchev
Telerik team
 answered on 25 Jun 2012
1 answer
119 views
Hi all,

I'm looking at the splitview demo on this link http://demos.kendoui.com/beta/mobile/splitview/index.html and I try to create the prototype using its demo source code with kendo trial version, but I think the data-role 'splitview' and 'pane' didn't work well. Can anyone help me, please? Or this feature is available for only the licensing version?

Thanks 
Kamen Bundev
Telerik team
 answered on 25 Jun 2012
1 answer
202 views
Hi,

Is it possible to use the sample codes for autocomplete in popup editor template?

http://demos.kendoui.com/beta/web/autocomplete/index.html

<script id="popup_editor" type="text/x-kendo-template">
...
  
<input name="test" id="test">
  
...
</script>
 
 
 <script>            
              $(document).ready(function () {
 
              $("#test").kendoAutoComplete({
                        dataSource: data,
                        filter: "startswith",
                        placeholder: "Select country...",
                       separator: ", "
                    });
</script>


Regards
Safak

Safak
Top achievements
Rank 1
 answered on 24 Jun 2012
1 answer
454 views
Here is the scenario
A french environment with globalization set to "FR-fr"
I included the french kendo culture script and added the call to kendo.culture( 'FR-fr')

I have an input field that contains a datetime in a french format
<input id="EventDate" type="text" value="24/08/2012"  name="EventDate" >

I tried to transform this input field to a kendo datepicker but failed to have the correct date value
I tried so many combinations from
$("#EventDate").kendoDatePicker({format: "D"})
to
$("#EventDate").kendoDatePicker({
           format: "D",
           value: new Date($("#EventDateEnd").val())
  });


The new kendo datepicker correctly displayed but never picked up the correct date value : Friday, August 24, 2012
nachid
Top achievements
Rank 1
 answered on 24 Jun 2012
3 answers
424 views
Is there a way to generate svg (or png/pdf) directly on the server?
All examples that I have seen so far, generate the svg in the browser and post it back to the server where it's converted to png/pdf.

I want to create a report on the server. So there is no chart visible in the client browser. The image must be created entirely on the server (where it will be embedded in PDF or Excel files that are created on the fly).

Any ideas?

Kind regards
Hartmut
Iliana Dyankova
Telerik team
 answered on 23 Jun 2012
0 answers
303 views
Hi:

You have two way of invoking Kendo UI, one way is via javascript (this is the Index view):
@{
    ViewBag.Title = "Employees";
}
<script type="text/javascript">
    $(document).ready(function () {
        //
        $("#kjsimpleGrid").kendoGrid({
            groupable: true, scrollable: true,
            sortable: true, pageable: true, filterable: true,
            dataSource: {
                transport: { read: { url: "/Grid/GetEmployees" } }
            },
            columns: [
                { title: "Id", field: "EmployeeID", width: 80 },
                { title: "Last", field: "LastName", width: 100 },
                { title: "First", field: "FirstName", width: 100 },
                { title: "Title", field: "Title", width: 200 },
                { title: "City", field: "City", width: 200 },
                { title: "Region", field: "Region"}]
        });
    });
</script>
<fieldset><legend>Employees</legend>
    <br />
    <div id="kjsimpleGrid">
 
    </div>
</fieldset>

The view is as follows:
//
/// <summary>
///  GET: /Grid/
/// </summary>
/// <returns></returns>
public ActionResult Index()
{
    return View( );
}
//
/// <summary>
///  GET: /Grid/GetEmployees/
/// </summary>
/// <returns></returns>
public JsonResult GetEmployees()
{
    var _emps =
        (from e in _db.Employees
            select new
            {
                EmployeeID = e.EmployeeID,
                LastName = e.LastName,
                FirstName = e.FirstName,
                Title = e.Title,
                TitleOfCourtesy = e.TitleOfCourtesy,
                BirthDate = e.BirthDate,
                HireDate = e.HireDate,
                Address = e.Address,
                City = e.City,
                Region = (e.Region == null ? "": e.Region)
            }).ToList();
    return Json(_emps, JsonRequestBehavior.AllowGet);
}

The Index view returns an empty view and gets the data asynchronously via call to GetEmployees.

Phil
Phil
Top achievements
Rank 2
 asked on 23 Jun 2012
7 answers
519 views
Hello, I am trying to create a layout which has a TabStrip with 5 items in it. However, when I was testing I noticed that on the Iphone 4, I can only fit 4 items in a TabStrip before the strip wraps and becomes two lines. Is there any way to control this behavior? I would really like to have 5 items on the TabStrip. I don't have this issue on one of my Android phones but that has a much larger screen and higher resolution.
Kamen Bundev
Telerik team
 answered on 23 Jun 2012
2 answers
161 views
Hi

I'm trying to figure out how to trigger a function when the scrollView 'gets over the hump' and changes page.

The doc says:

Fires when the widget page is changed.

Event data

page : jQueryObject
The current page (zero based index)

but I can't make any sense out of this though it looks right.

What i'd really like is to access the page information and the last clientY coordinates the user touched. 

Any idea how to do this? Thanks!

Enjoy,

Elias
Elias
Top achievements
Rank 1
 answered on 23 Jun 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
DropDownTree
ListBox
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
Styling
ColorPicker
Pager
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
Licensing
PivotGridV2
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
LLM Kit
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?