Telerik Forums
Kendo UI for jQuery Forum
1 answer
358 views
Hi – I have a grid where one of the columns is a lookup (dropdown list) – I set the editor and template properties as shown here and everything was working.

However now I am attempting to use requirejs and I receive the following error on the template property when the grid is loading - Uncaught ReferenceError:
getFullName is not defined.


Here is the relevant code:
 
Invitations.htm
<script data-main="/js/invitations" src="/js/lib/require.js" type="text/javascript">
</script>
...
<div id="gridInvitations">
</div>

Invitations.js
require(['/js/common.js'], function (common) {   
    require(['app/mainInvitations'], function(main) {
        /* Must read the query string '?eventId=x' */
        var qryString = location.search;
        var eventId = qryString.substr(qryString.indexOf("=") + 1);       
       main.initGrid(eventId);
    });
});

Common.js
require.config({
    baseUrl: "/js/lib",
    paths: {
        app: '../app',      
        jquery: '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min',
        js: '..',       
       kendo: '../kendo/kendo.web.min'
    },
  shim: {
       kendo: {
      deps: ["jquery"]
        }
   },
    deps: ['js/utils', 'js/json2'],
    callback: function () {
    }
});

MainInvitations.js
define(['app/mainInvitations', "js/utils", "jquery", "kendo"], function (main, utils, $, k) {

    $(document).ready(function () {
    });

    var contactList = [];
    var gridDataSource;

    function initGrid(eventId) {

        $("#gridInvitations").kendoGrid({
            autoBind: false,
            editable: { mode: 'inline' },
            toolbar: [{ name: "create"}],
            columns:
                [
                    { field: 'invitationId', title: 'invitationId', width: "100px", hidden: true },
                    { field: 'eventId', title: 'eventId', hidden: true },
                    { field: "contactId", title: "Contact", width: "225px",
                        editor: contactDropDownEditor,
                        template: "#=getFullName(contactId)#",
                        footerTemplate: "Total:  #=count #"
                    },
                    { field: 'inviteType', title: 'Invite Type' },
                    { field: 'inviteSentDate', title: 'Invitation Sent', format: "{0: yyyy-MM-dd HH:mm:ss}" },
                    { field: 'rsvpStatus', title: 'RSVP', hidden: false },
                    { field: 'rsvpDate', title: 'RSVP Date', format: "{0: yyyy-MM-dd}" },
                    { field: 'rsvpComments', title: 'RSVP Comments' },

                    { command: ["edit", "destroy"], title: "&nbsp;", width: "200px" }
                ],

            dataSource: createGridDataSource(eventId),
            selectable: 'row',
            sortable: true,
            filterable: true
        });


        /* Get list of contacts and assign them to grid column */
        $.ajax({
            url: utils.getBaseServicesUrl() + "/wcfDataServices/contacts.svc/contacts_getList",
            dataType: "json",
            success: function (result) {

                contactList = result.d;
                gridDataSource.fetch();
                console.log(contactList);
            },
            error: function () {
                alert('Error fetching contactList');
            }
        });

    }

    function createGridDataSource(eventId) {

        var dataSource = new kendo.data.DataSource({
            transport: {
                read: function (options) {

                    $.ajax({
                        url: utils.getBaseServicesUrl() + "/wcfDataServices/invitations.svc/tblEvents(" + eventId + ")/tblInvitations",
                        dataType: "json",
                        success: function (result) {
                            options.success(result);
                        }
                    });
                } 

            },
            /*
            parameterMap: function (data, type) {
            return JSON.stringify(data);
            },
            */
            schema: {
                data: "d",
                model: {
                    id: "invitationId",
                    fields: {
                        invitationId: { type: "number", editable: false },
                        eventId: { type: "number", editable: false },
                        contactId: { type: "number" },
                        inviteType: { type: "string" },
                        inviteSentDate: { type: "date" },
                        rsvpStatus: { type: "string" },
                        rsvpDate: { type: "date" },
                        rsvpComments: { type: "string", validation: { required: true} },
                        lastUpdated: { type: "date" },
                        lastUpdatedBy: { type: "string" }
                    }
                }
            },

            aggregate: { field: "contactId", aggregate: "count" }

        });

        gridDataSource = dataSource;
        return gridDataSource;

    }




    function contactDropDownEditor(container, options) {

        $('<input data-bind="value:' + options.field + '"/>')

        .appendTo(container)
        .kendoDropDownList({
            dataTextField: "FullName",
            dataValueField: "contactId",
            dataSource: contactList,
            optionLabel: ""
        });


    }

    
    function getFullName(contactId) {
        for (var idx = 0, length = contactList.length; idx < length; idx++) {
            if (contactList[idx].contactId === contactId) {
                return contactList[idx].FullName;
            }
        }
    }
    
    
    return {

        initGrid: initGrid, 
        getFullName: getFullName
    }

});


It took me a while to finally get the lookup column working in the grid and I'm now stuck on this problem - any suggestions would be greatly appreciated.  As I mentioned, this line is causing the problem: template: "#=getFullName(contactId)#",

Thanks a lot

Brian


 
Alexander Popov
Telerik team
 answered on 22 Aug 2013
4 answers
173 views
Hi,

I'm I have created an example that illustrates my problem: http://jsfiddle.net/tcTRy/11/

I believe that this is the expected behavior, but is there a workaround to don't loose selection?

In my case I have a listview that when is selected show some details, and some of the details causes the list view datasource data to change. For instace if I edit the Title this will update the Title in the listview, although it would be nice to don't loose the selection, or else the details will be hidden.

Any ideas?

Thanks,
Ricardo
Kiril Nikolov
Telerik team
 answered on 22 Aug 2013
1 answer
95 views
Hello,

when using on mobile, when tap on the arrow it feels slow because of the lag to wait the double tap.

Some touch library have a fast tap feature, have you a solution to have it working with a better user experience?

Dimo
Telerik team
 answered on 22 Aug 2013
1 answer
318 views
I have a Hierarchical grid that is bound to the server and is in MVC  (.DataSource(d => d.Server()))  

When the grid first loads I'd like the grid to expand the first row by default so the detail view is showing.

Can this be done without Javascript (preferred) or in Javascript if needed.


Petur Subev
Telerik team
 answered on 22 Aug 2013
1 answer
128 views
Hi,

I've been fighting this issue for a while, and I can't seem to find what causes it (or if it's by design). When I center my window the window opens farther from the top than it does from the bottom, instead if it being exact. So if the screen is say 1000px tall, and the window is 800px. When I center it, instead of appearing 100px from the top and 100px from the bottom as you would expect, it appears to be about 150px from the top and 50px from the bottom. It's like its stealing some of the bottom. Can you give me any pointers as to how this can be overcome so I can get to center exactly in the middle?

Thanks
Jason
Dimo
Telerik team
 answered on 22 Aug 2013
1 answer
382 views
Hello,
Since the drawer does not support in-place navigation, I want to tweak the splitview to show/hide the sidepanel in manner similar to the drawer.
Can someone point me in the right direction? So far i have managed to get a quick,snap-in/out, action but I want something more soft, an animation of the side panel's width.

This is what I am using right now:
$("#main-pane").css("-webkit-box-flex","1000");
$("#main-pane").css("-webkit-flex","1000");
$("#side-pane").animate({ width: "-=350" }, 750);

Thanks
Alexander Valchev
Telerik team
 answered on 22 Aug 2013
1 answer
63 views
I have a client who wants to specify a handful of stops on a slider, but they are not exactly the same distance apart. Say I want to stop on values of 24, 49, 73, and 97. How could I manage to do this with the Kendo slider?
Hristo Germanov
Telerik team
 answered on 22 Aug 2013
1 answer
218 views
 What is the best way to handle the IE 10 "X" being displayed in a text box when the loading spinner is being displayed?

See attached file for a screen shot of it in action.
Dimo
Telerik team
 answered on 22 Aug 2013
1 answer
105 views
I am trying to use the Scheduler with PHP wrappers, the data returns in a way that LOOKS like it should work...but doesn't for some reason.  Here is how it works:
The initial page loads:
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="../kendo/styles/kendo.common.min.css" rel="stylesheet" />
    <link href="../kendo/styles/kendo.default.min.css" rel="stylesheet" />
    <script src="../kendo/js/jquery.min.js"></script>
    <script src="../kendo/js/kendo.all.min.js"></script>
</head>
 
 
<script>
 
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            dataType: "html",
            data: {
                request: 'calendar'
            },
            url: "../ajaxlistener.php",
            cache: false,
            success: function (data) {
 
                $("#cal").html(data);
 
            }
        });
    });
 
 
 
</script>
 
<style scoped>
    #people {
        background: url('i/2oa8kvmz.bmp') transparent no-repeat;
        height: 115px;
        position: relative;
    }
    #alex {
        position: absolute;
        left: 404px;
        top: 81px;
    }
    #bob {
        position: absolute;
        left: 519px;
        top: 81px;
    }
    #charlie {
        position: absolute;
        left: 634px;
        top: 81px;
    }
</style>
<body>
 
<div id="people">
    <input checked type="checkbox" id="alex" value="1">
    <input checked type="checkbox" id="bob" value="2">
    <input type="checkbox" id="charlie" value="3">
</div>
 
<div id="cal">
 
</div>
 
</body>
</html>
After, as you can see, the first call to the listener is made.  I am not posting the code to the listener, as it just redirects to the calendar handler:
include("includes/calendar.class.php");
 
$cal = new calendar();
if(!isset($_GET['action'])){
    echo $cal->makeCalBase();
}else{
    $rawData = json_decode(file_get_contents('php://input'));
    $action = $_GET['action'];
    if($action == 'read'){
        echo $cal->loadCal();
    }elseif($action == 'create'){
        echo $cal->saveCal($rawData);
    }
The class is:
<?php
class calendar
{
    private $uid;
    private $calendarid;
    private $today;
    private $sched;
    private $rawData = array();
    private $json;
    private $timezone = "";
    public $display;
 
    public function date_normalizer($d)
    {
        if ($d instanceof DateTime) {
            return $d->getTimestamp();
        } else {
            return strtotime($d);
        }
    }
 
    private function getLocations()
    {
        $rArray = array();
        $get = "SELECT location_id, name, address1 FROM locations ORDER BY location_id ASC";
        $exe = new Query($get, __LINE__, __FILE__);
        $x = 0;
        while ($r = $exe->fetch_assoc_array()) {
            $rArray[$x]['text'] = ucwords($r['name']);
            $rArray[$x]['value'] = $r['location_id'];
            if (trim($r['address1']) != "") {
                $rArray[$x]['color'] = "#" . substr(sha1($r['address1']), 0, 6);
            } else {
                $rArray[$x]['color'] = "#" . substr(sha1(time() * $r['location_id']), 0, 6);
            }
            $x++;
        }
 
        return $rArray;
    }
 
    public function makeCalBase()
    {
 
        $transport = new \Kendo\Data\DataSourceTransport();
 
        $create = new \Kendo\Data\DataSourceTransportCreate();
 
        $create->url('../calendarcontrol.php?action=create')
            ->contentType('application/json')
            ->type('POST');
 
        $read = new \Kendo\Data\DataSourceTransportRead();
 
        $read->url('../calendarcontrol.php?action=read')
            ->contentType('application/json')
            ->type('POST');
 
        $update = new \Kendo\Data\DataSourceTransportUpdate();
 
        $update->url('../calendarcontrol.php?action=update')
            ->contentType('application/json')
            ->type('POST');
 
        $destroy = new \Kendo\Data\DataSourceTransportDestroy();
 
        $destroy->url('../calendarcontrol.php?action=destroy')
            ->contentType('application/json')
            ->type('POST');
 
        $transport->create($create)
            ->read($read)
            ->update($update)
            ->destroy($destroy)
            ->parameterMap('function(data) {
                      return kendo.stringify(data);
                  }');
 
        $model = new \Kendo\Data\DataSourceSchemaModel();
 
        $taskIDField = new \Kendo\Data\DataSourceSchemaModelField('taskID');
        $taskIDField->type('number')
            ->from('entry_id')
            ->nullable(true);
 
        $titleField = new \Kendo\Data\DataSourceSchemaModelField('title');
        $titleField->from('event_title')
            ->defaultValue('No title')
            ->validation(array('required' => true));
 
        $startField = new \Kendo\Data\DataSourceSchemaModelField('start');
        $startField->type('date')
            ->from('start_time');
 
        $startTimezoneField = new \Kendo\Data\DataSourceSchemaModelField('startTimezone');
        $startTimezoneField->from('start_timezone');
 
        $endField = new \Kendo\Data\DataSourceSchemaModelField('end');
        $endField->type('date')
            ->from('end_time');
 
        $endTimezoneField = new \Kendo\Data\DataSourceSchemaModelField('endTimezone');
        $endTimezoneField->from('end_timezone');
 
        $isAllDayField = new \Kendo\Data\DataSourceSchemaModelField('isAllDay');
        $isAllDayField->type('boolean')
            ->from('all_day');
 
        $descriptionField = new \Kendo\Data\DataSourceSchemaModelField('description');
        $descriptionField->type('string')
            ->from('details');
 
        $recurrenceIdField = new \Kendo\Data\DataSourceSchemaModelField('recurrenceId');
        $recurrenceIdField->from('recure_id');
 
        $recurrenceRuleField = new \Kendo\Data\DataSourceSchemaModelField('recurrenceRule');
        $recurrenceRuleField->from('recure_rule');
 
        $recurrenceExceptionField = new \Kendo\Data\DataSourceSchemaModelField('recurrenceException');
        $recurrenceExceptionField->from('recure_exception');
 
        $ownerIdField = new \Kendo\Data\DataSourceSchemaModelField('ownerId');
        $ownerIdField->from('location_id')
            ->defaultValue(0);
 
        $model->id('entry_id')
            ->addField($taskIDField)
            ->addField($titleField)
            ->addField($startField)
            ->addField($endField)
            ->addField($startTimezoneField)
            ->addField($endTimezoneField)
            ->addField($descriptionField)
            ->addField($recurrenceIdField)
            ->addField($recurrenceRuleField)
            ->addField($recurrenceExceptionField)
            ->addField($ownerIdField)
            ->addField($isAllDayField);
 
        $schema = new \Kendo\Data\DataSourceSchema();
        $schema->data('data')
            ->errors('errors')
            ->model($model);
 
        $dataSource = new \Kendo\Data\DataSource();
 
        $dataSource->transport($transport)
            ->schema($schema)
            ->batch(true)
            ->addFilterItem(array(
                'logic' => 'or',
                'filters' => array(
                    array('field' => 'owner_id', 'operator' => 'eq', 'value' => 1),
                    array('field' => 'owner_id', 'operator' => 'eq', 'value' => 2),
                )
            ));
 
        $resource = new \Kendo\UI\SchedulerResource();
        $resource->field('owner_id')
            ->title('owner_id')
            ->dataSource($this->getLocations());
 
        $scheduler = new \Kendo\UI\Scheduler('scheduler');
        $scheduler->timezone("Etc/UTC")
            ->date(new DateTime())
            ->height(600)
            ->addResource($resource)
            ->addView(array('type' => 'day', 'startTime' => new DateTime()),
                array('type' => 'week', 'selected' => true, 'startTime' => new DateTime()), 'month', 'agenda')
            ->dataSource($dataSource);
 
        return $scheduler->render();
 
    }
 
    public function makeEmptyCal()
    {
 
    }
 
    public function saveCal($data)
    {
        $insertData = array(array());
 
        $queryList = "";
 
 
        foreach ($data->models AS $uselessVar => $usableData) {
 
            $dataArray = get_object_vars($usableData);
 
            if ($dataArray['entry_id'] !== null) {
 
            } else {
                $cols = "(";
                $values = "(";
                foreach ($dataArray AS $field => $val) {
                    if ($field == "start_time" || $field == "end_time") {
                        $val = date("Y-m-d H:i:s",$this->date_normalizer($val));
                    }
                    if ($field != 'entry_id') {
                        $cols .= "{$field},";
                        $values .= "'" . trim($val) . "',";
                    }
                }
 
                $cols .= "owner_id)";
                $values .= "{$this->uid})";
 
                $queryList .= "INSERT INTO scheduler_data {$cols} VALUES {$values};\n";
            }
        }
 
        if ($queryList != "") {
            new Query($queryList, __LINE__, __FILE__);
        }
 
        return $this->loadCal();
    }
 
    public function loadCal()
    {
        $getData = "SELECT entry_id, event_title, start_time, end_time, all_day, details, recure_id, recure_rule, recure_exception, location_id FROM scheduler_data WHERE owner_id = 0 OR owner_id = {$this->uid}";
        $exe = new Query($getData, __LINE__, __FILE__);
 
        $returnObject = new stdClass();
 
        $returnObject->models = array();
        $x=0;
        while ($r = $exe->fetch_assoc_array()) {
            $returnObject->models[$x] = new stdClass();
            foreach ($r AS $c => $v) {
 
                $c = str_replace(array("entry_id","event_title","start_time","end_time","all_day","details","recure_id","recure_rule","recure_exception","location_id"), array("TaskID","Title","Start","End","IsAllDay","Description","RecurrenceRule","RecurrenceID","RecurrenceException","OwnerID"),$c);
 
                if ($c != 'start_time' && $c != 'end_time' && $c != "Start" && $c != "End"){
 
                    $v = trim(stripslashes($v));
                    if($v == ""){
                        $v = null;
                    }
 
                    if(preg_match("/_id/",$c) || preg_match("/ID/",$c)){
                        $returnObject->models[$x]->$c = intval($v);
                    }elseif($c == 'all_day'){
                        if($v == '0'){
                            $returnObject->models[$x]->$c = false;
                        }else{
                            $returnObject->models[$x]->$c = true;
                        }
                    }else{
                        $returnObject->models[$x]->$c = $v;
                    }
 
                }else{
                    $returnObject->models[$x]->$c = "/Date(" . $this->date_normalizer($v) . ")/";
 
                }
 
            }
            $x++;
        }
 
        return "jQuery(" . json_encode($returnObject->models) . ")";
    }
 
    function __construct($cid = 0)
    {
        $this->calendarid = $cid;
        $this->uid = $_SESSION['user_id'];
        $this->today = time();
    }
}
 
 
?>
And i am really confused because it seems to return correct data:
jQuery([{"entry_id":1,"event_title":"Test Event","start_time":"\/Date(1376840734)\/","end_time":"\/Date(1376842534)\/","all_day":false,"details":null,"recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":2,"event_title":"Another Event","start_time":"\/Date(1377006334)\/","end_time":"\/Date(1377008134)\/","all_day":false,"details":"Some more info about that event","recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":3,"event_title":"Test Event","start_time":"\/Date(1376919934)\/","end_time":"\/Date(1376921734)\/","all_day":false,"details":"This is a test event","recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":4,"event_title":"DATA!!","start_time":"\/Date(1377024633)\/","end_time":"\/Date(1377026433)\/","all_day":false,"details":null,"recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":5,"event_title":"DATA!!","start_time":"\/Date(1377024633)\/","end_time":"\/Date(1377026433)\/","all_day":false,"details":null,"recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":6,"event_title":"asdfasdfasdf","start_time":"\/Date(1377021033)\/","end_time":"\/Date(1377022833)\/","all_day":false,"details":null,"recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":7,"event_title":"asdasdasd","start_time":"\/Date(1376845910)\/","end_time":"\/Date(1376847710)\/","all_day":false,"details":null,"recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":8,"event_title":"No title","start_time":"\/Date(1376784000)\/","end_time":"\/Date(1376784000)\/","all_day":true,"details":null,"recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":9,"event_title":"No title","start_time":"\/Date(1376784000)\/","end_time":"\/Date(1376784000)\/","all_day":true,"details":null,"recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":10,"event_title":"asdasdasd","start_time":"\/Date(1376939633)\/","end_time":"\/Date(1376941433)\/","all_day":false,"details":null,"recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":11,"event_title":"Some Event","start_time":"\/Date(1377026532)\/","end_time":"\/Date(1377028332)\/","all_day":false,"details":null,"recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0},{"entry_id":12,"event_title":"Yet another event!","start_time":"\/Date(1377031457)\/","end_time":"\/Date(1377033257)\/","all_day":false,"details":"Some info aout said event","recure_id":0,"recure_rule":null,"recure_exception":null,"location_id":0}])

I guess I am missing something....?    Any help would be greatly appreciated.
Rosen
Telerik team
 answered on 22 Aug 2013
2 answers
99 views
I am not sure if this is expected behavior, but I have set a min-height property for paragraphs in a custom style sheet. However when this is applied to the editor, every time a paragraph is clicked the "move" cursor appears and the whole paragraph is then selected making it difficult to enter text. This seems to only be happening in IE and not Firefox.

One of the reasons I am doing this as I don't want paragraphs creating margins, however I do want spaces between paragraphs if required.

margin:0cm;
margin-bottom:.0001pt;
min-height: 14px;

Please see attached screenshot when applied to your demo.
Greg Lynne
Top achievements
Rank 1
 answered on 21 Aug 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?