Telerik Forums
Kendo UI for jQuery Forum
0 answers
194 views

I am pretty New to Javascript and jQuery.


I am now just learning to build User Interface and was checking out KendoUI. I must say its amazing. 


I want to have data in a local file on my computer. Access the data and show it in grid/table.


I want to be able to edit and save the data back to the local file using the user interface in the browser.


I am looking at : http://demos.kendoui.com/web/grid/editing.html


Looking at the source, the data is obtained/saved from/to a remote server:


<script>
            $(document).ready(function () {
                var crudServiceBaseUrl = "http://demos.kendoui.com/service",
                    dataSource = new kendo.data.DataSource({
                        transport: {
                            read:  {
                                url: crudServiceBaseUrl + "/Products",
                                dataType: "jsonp"
                            },
                            update: {
                                url: crudServiceBaseUrl + "/Products/Update",
                                dataType: "jsonp"
                            },
                            destroy: {
                                url: crudServiceBaseUrl + "/Products/Destroy",
                                dataType: "jsonp"
                            },
                            create: {
                                url: crudServiceBaseUrl + "/Products/Create",
                                dataType: "jsonp"
                            },
                            parameterMap: function(options, operation) {
                                if (operation !== "read" && options.models) {
                                    return {models: kendo.stringify(options.models)};
                                }
                            }
                        },
                        batch: true,
                        pageSize: 30,
                        schema: {
                            model: {
                                id: "ProductID",
                                fields: {
                                    ProductID: { editable: false, nullable: true },
                                    ProductName: { validation: { required: true } },
                                    UnitPrice: { type: "number", validation: { required: true, min: 1} },
                                    Discontinued: { type: "boolean" },
                                    UnitsInStock: { type: "number", validation: { min: 0, required: true } }
                                }
                            }
                        }
                    });
 
 
                $("#grid").kendoGrid({
                    dataSource: dataSource,
                    navigatable: true,
                    pageable: true,
                    height: 400,
                    toolbar: ["create", "save", "cancel"],
                    columns: [
                        "ProductName",
                        { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: 150 },
                        { field: "UnitsInStock", title: "Units In Stock", width: 150 },
                        { field: "Discontinued", width: 100 },
                        { command: "destroy", title: " ", width: 110 }],
                    editable: true
                });
            });
        </script>


How can I possibly have this jSON file on my computer and edit/save the data on it.


Any help with a working example shall be hight appreciated.


Thanks,


Praney 

Praney Behl
Top achievements
Rank 1
 asked on 11 Aug 2012
1 answer
939 views
I'm trying to open a window where content page has uses a template to display the data.
The content page it self works fine just entering the url but when I try to open it as a window nothing happens.
     var window = $("#window");
    
   window.kendoWindow({
        width: "505px",
        height: "315px",
        title: "Mail",
        actions: ["Refresh", "Maximize", "Close"],
        content:"inbox/getemail.aspx?msgid="+msgid,
        iframe:false
    });
 
    window.data("kendoWindow").open();

//content page 
script language="javascript">
 
var messageData;
 
$.fn.getMessageData = function(){
     
    messageData =
    {      
        time:'2012-07-26 12:34:50',
        sender:'test@test.com',
        subject:'Testing message data'     
    };
};
 
$(function(){  
    var template = kendo.template($("#template").html());
    $.fn.getMessageData();     
    $("#preview").html(template(messageData));
        
});
 
</script>
 
<script type="text/x-kendo-template" id="template">
    <h3>#= subject #</h3>
    <h4>posted on #= time # by <strong>#= sender #</strong></h4
</script>
 
 <div id="preview"></div>
John DeVight
Top achievements
Rank 1
 answered on 10 Aug 2012
0 answers
445 views
Hi folks,

I'm using a treeview from a HierarchicalDataSource and wanted to be able to get the element from the treeview if it matched all the properties that I specified. My initial data looked something like this:

[{
    id:'2022',
    text:'Folder1',
    items: [{
        id:'3202',
        text:'Sub-Folder1'
    }, {
        id:'1234',
        text:'Sub-Folder2',
        moo: true
    }]
}]

I wanted to be able to get the list item element (<li>) for any particular item so I built a function to do it and thought I'd share. You can use my function like this (in this example I want to get the element for the item with the id '3202':

var liElement = $('#treeView').data('kendoTreeView').search({id:'3202'});

You can also search on multiple properties:

var liElement = $('#treeView').data('kendoTreeView').search({id:'1234', moo: true});

To enable this functionality, after creating a treeview with a HierarchicalDataSource, add this code (assumes your treeview element is #treeView - change as required):

$("#scenegraph-treeview").data('kendoTreeView').search = function (json, source) {
    if (json !== undefined) {
        var data = source || this.dataSource,
            child, item, i, k, match, allMatched;
 
        // If the data has the properties we need
        if (data && data._data) {
            child = data._data;
 
            // If the array has items
            if (child.length) {
                // Loop the array items
                for (i = 0; i < child.length; i++) {
                    item = child[i];
 
                    console.log('Checking child ' + i + ' id ' + item.id);
 
                    // Check each json property against the current item's properties
                    // and if they all match, grab the tree item based on it's UID
                    allMatched = true;
                    for (k in json) {
                        if (json.hasOwnProperty(k)) {
                            if (item[k] !== json[k]) {
                                // The item doesn't have all the properties
                                // that the json object does
                                allMatched = false;
                                break;
                            }
                        }
                    }
 
                    if (allMatched) {
                        // We've found a match, grab the tree item from the UID and return it
                        return this.findByUid(item.uid);
                    } else {
                        // We didn't find what we were looking for so search the children
                        if (item.children) {
                            match = this.search(json, item.children);
                            if (match) {
                                return match;
                            }
                        }
                    }
                }
            }
        }
    }
};

Hope this helps someone out!

Rob - Irrelon Software Limited
Rob
Top achievements
Rank 1
 asked on 10 Aug 2012
0 answers
121 views
Hi, the whole form was working properly before, and after I decorated some input fields of the form with kendo, in the action, I var_dump the form, those kendo inputs are missing and everything else is all good.

Any idea guys ? Please help me to save my hair, cheers.

I also checked with other UI plugins, it's all good.

Is this cause by the version I chose, open oource one ?
KJ
Top achievements
Rank 1
 asked on 10 Aug 2012
2 answers
187 views
I'm in the midst of writing a single page application with routes.  The way the application functions is:
  1. DataSource with list of items is bound to a Kendo Grid
  2. User clicks an item on the Grid and is taken to a new route which contains the ID of the item the user selected.  Example: www.mydomain.com/#itemID=1
  3. This ID is used in a DataSource to refresh the item the user chose.  This is also done in case the user bookmarks the specific route.  In such an event the Grid can be bypassed.
The binding of the Grid works great and I'm able to capture the ID of the chosen item and redirect to my new route.  I'm also able to create a new datasource with the ID of the item selected and return data from the server.

Here's where I'm stuck.  I'm trying to bind the returned record to HTML controls using an MVVM pattern, but it seems the Kendo binding context assumes that DataSource is a collection (where in my case it's a single record).  What is the correct approach for this?  Is there a way to bind controls in a DIV to a single record in a DataSource?
Jeff
Top achievements
Rank 1
 answered on 10 Aug 2012
2 answers
288 views
I am trying to implement a MVVM pattern for my website's login function.

The site returns with status code 401 when authentication fails.  The goal would be to:
  1. Update my view model to indicate that the user is not authenticated.  Example: viewModel.set("authenticated", false)
  2. When authenticated is false, display a Kendo window with the username/password prompt
  3. Then the user presses submit within this window, fire my login method
Everything works except I am having the following problems:
  1. I can't find a way to bind the open/close state of the Kendo window (my login window) to the authenticated property of my viewModel
  2. When I bind to the input of type password, it seems to be one-way.  I am able to get the password the user typed in and pass this up to my web method, but during the login function I clear the password viewModel.set("password", "") but the input control does not update.  If I change it to a regular input with type text it seems to work.
Jeff
Top achievements
Rank 1
 answered on 10 Aug 2012
0 answers
96 views
Hi,

As a newbie to Kendo UI, I understand that Kendo has its own MVVM implementation.  There is some support for KnockoutJS with Kendo UI widgets, but from what I've read, I'll get the best results if I use Kendo's MVVM rather than KnockoutJS with the Kendo UI widgets.

If I have a page that contains a mixtures of controls - Kendo UI, jQuery UI, and basic HTML element, is it possible to use a combination of Kendo's MVVM and KnockoutJS on the same page?  I guess a second question would be, can the Kendo UI MVVM be used for third party controls, or does it only work with Kendo UI widgets?

Thanks,
Notre
Notre
Top achievements
Rank 1
 asked on 10 Aug 2012
0 answers
142 views
Hi,
I have a telerik mvc grid in my application which populates data that would contain random number of columns ( I mean to say the total number of columns might change each time). Now that when i do resizing on those columns and click on grid refresh or sort, the resizing settings on columns doesn't seem to retain! So, Is there a way i could retain those column resizing settings made by the user even after clicking on grid footer refresh or on sorting?

I have gone through a demo in the Telerik Mvc Grid extensions (Column Resizing) but then there it's like fixed number of column always and so it'd retain all those settings made by the user.

I hope the attachment might provide you a clear idea about my question.
 

Thanks,
Kishore Kumar
Kishore
Top achievements
Rank 1
 asked on 10 Aug 2012
1 answer
262 views
I am experimenting with "kendo.Class.extend()".

When I inherit a new class from a base class, how can i call the base class constructor from within the derived class constructor?

The below didn't work for me.

var ClsPerson = kendo.Class.extend(
                {
                    FirstName:"<none>", LastName: "<none>", Married: false, 
                    Display: function() { alert("I am " + this.FirstName + " " + this.LastName); },
                    init: function(FirstName, LastName)
                    {
                        if (FirstName) this.FirstName = FirstName;
                        if (LastName) this.LastName = LastName;
                    }
                });
var ClsParent = ClsPerson.extend(
                {
                    SpouseName: "<none>",
                    init: function(FirstName, LastName, SpouseName)
                    {
                        //if (FirstName) this.FirstName = FirstName;
                        //if (LastName) this.LastName = LastName;
                        ClsPerson(FirstName, LastName);
                        if (SpouseName) this.SpouseName = SpouseName;
                    }
                });

var Parent1 = new ClsParent("Sakthivel", "S", "Sangitha S");
Parent1.Display();
alert(Parent1.SpouseName);

I tried calling the base class constructor like "ClsPerson(FirstName, LastName); ", but didn't get the desired results.
Maxim
Top achievements
Rank 1
 answered on 10 Aug 2012
2 answers
137 views
I am utilizing combo boxes in a form using declarative syntax.  Both are remote dataSource dependent and I have had some challenges in getting them to work properly, but I seem to finally have it down, except for one minor detail.

I want them to autobind and I have that enabled using the declarative syntax, but when I have them autobind and there is a valid value that they are looking up, the last one to finish grabs focus, and would rather a different control on the form get first focus.  I don't really want to embed view code into the dataSources, so my workaround at this point is to disable them initially and then renable them with a 2.5 second timer to ensure they have enough time to update.  This works, but it would be better if I could either tie it to an event related to the controls, or if I could prevent them from grabbing focus altogether.

Any thoughts would be appreciated.

Thanks.
Paul
Top achievements
Rank 1
 answered on 10 Aug 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
Application
Map
Drag and Drop
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
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?