Telerik Forums
Kendo UI for jQuery Forum
0 answers
142 views
Hi,

I am using Kendo UI Web and am trying to format a DateTime. The code snippet is shown as below:

$(

 

"#reportListGrid").kendoGrid({

 

columns: [

{ field:

 

"StartDateTime", title: "Upload Start Date", type: "date", width: "70px", format: "{0:dd/MM/yyyy}"},
...

My model contains the DateTime data but displays as shown below
2012-11-27T11:22:16.5049451-06:00

I have also tried the following but similarly does not work
template: '#= kendo.toString(StartDateTime,"MM/dd/yyyy") #'

Please help. Thanks in advance.

 

andy
Top achievements
Rank 1
 asked on 27 Nov 2012
2 answers
240 views
If you add a model programmatically to your grid datasource - for example using the add()-method - set the corresponding row to edit mode and cancel the edit without changing anything, the model will be deleted.

This is the kind of behaviour you'd expect if you add an empty row to the grid and then cancel the edit without entering any information.

See this fiddle: http://jsfiddle.net/MM5Ke/3/

To reproduce, click the edit button, then the update button. The row will disappear. 
There's also an uncaught TypeError.

If this is to be intended behaviour, errors should be dealt with and the behaviour should be better documented.
Alexander Valchev
Telerik team
 answered on 27 Nov 2012
1 answer
264 views

here i will explain what i am facing exactly in kendo ui mvc.

my requarement is displaying values in Grid from the database based on the comboBox selection.

here i successfully binding values from database to combobox ,as well as passing selected value to controller and view AND again retriving row information up to controller.but the problem is row details is not binding to grid (in view)..please let me know how to bind those values in view.....thanks in advance

code in Index.cshtml page

@{

    ViewBag.Title = "Home Page";

}

<h2>@ViewBag.Message</h2>

<div id="tshirt-view" class="k-header">

    <h3>

        Employee Name

    </h3>

    <input id="comboBox1" />

    <br />

    <h3>

        Employee Details

    </h3>

    <div id="empgrid">

    </div>

</div>

<script type="text/javascript">

    var cmbvalue;

    var s;

    var dataSource = new kendo.data.DataSource({

        transport: {

            read: "/Home/PutempDataValue"

            //            update: {

            //                url: "/Products/Update",

            //                type: "POST"

            //            },

            //            destroy: {

            //                url: "/Products/Destroy",

            //                type: "POST"

            //            },

            //            create: {

            //                url: "/Products/Create",

            //                type: "POST"

            //            }

        },

        schema: {

            model: {

                id: "eid",

                fields: {

                    eid: {

                        //this field will not be editable (default value is true)

                        editable: false,

                        // a defaultValue will not be assigned (default value is false)

                        nullable: true

                    },

                    ename: {

                        validation: { //set validation rules

                            required: true

                        }

                    },

                    age: {

                        //data type of the field {Number|String|Boolean} default is String

                        type: "number",

                        validation: {

                            required: true,

                            min: 25

                        }

                    },

                    salary: {

                        type: "long",

                        validation: {

                            min: 5000

                        }

                    }

                }

            }

        },

        // determines if changes will be send to the server individually or as batch

        batch: true

        //...

    });

    $(document).ready(function () {

        //comboBoxInformation

        $("#comboBox1").kendoComboBox({

            change: function (e) {

                cmbvalue = $("#comboBox1").data("kendoComboBox").text();

                //var gridvalue = $("#empgrid").data("kendoGrid");

                //alert(gridvalue);

                debugger

                $.ajax({

                    url: "Home/PutempDataValue", //   controllerName/MethodName

                    type: 'POST',

                    contentType: "application/json; charset=utf-8",

                    data: '{"cmbvalue":"' + cmbvalue + '"}',

                    dataSource: {

                        type: "json",

                        serverFiltering: true,

                        serverPaging: true,

                        pageSize: 5,

                        transport: {

                            read: {

                                url: "Home/PutempDataValue"

                            }

                        }

                    }

                });

               // gridvalue.refresh();

                // Console:debug(gridvalue);

            },

            index: 0,

            dataTextField: "ename",

            dataValueField: "eid",

            filter: "contains",

            dataSource: {

                type: "json",

                serverFiltering: true,

                serverPaging: true,

                pageSize: 5,

                transport: {

                    read: "Home/GetData"

                }

            }

        });

        //gridInformation

        s = $("#empgrid").kendoGrid({

            pageable: true,

            toolbar: ["create", "save", "cancel"],

            editable: true,

            async: false,

            //            dataSource:dataSource,

            //                        dataSource: {

            //                            type: "json",

            //                            serverFiltering: true,

            //                            serverPaging: true,

            //                            pageSize: 5,

            //                            transport: {

            //                                read: {

            //                                    url: "Home/PutempDataValue"                                 

            //                                }

            //                            }

            //                        },

            //            dataSource: {

            //                transport: {

            //                    read: {

            //                        type: "json",

            //                        contentType: "Application/json; charset=utf-8",

            //                        url: "Home/PutempDataValue"

            //                    }

            //                }

            //            },

            columns: [

                        { title: 'Age', field: 'age', width: '25%', flex: 1, sortable: true },

                        { title: 'Employee Id', field: 'eid', width: '25%', sortable: true },

                        { title: 'Employee Name', field: 'ename', width: '35%', flex: 1, sortable: true },

                        { title: 'Salary', field: 'salary', width: '35%', flex: 1, sortable: true }

                      ],

            sortable: true

        });

    });

</script>

code in Controller

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;

using System.Data;

using KendoUIMvcApplication1.Models;

namespace KendoUIMvcApplication1.Controllers

{

    public class HomeController : Controller

    {

        string Value;// = string.Empty;

        public ActionResult Index()

        {

            //ViewBag.Message = "Welcome to ASP.NET MVC!";

            //Movie objMv=new Movie();

            //var products = from m in objMv.subname select m;

            ////DataTable dt = Movie.GetData();

            ////return View(dt);

            var products = new Movie().GetData();

            ViewData["products"] = products;

            return View();

        }

        [AcceptVerbs(HttpVerbs.Get)]

        public JsonResult GetData()

        {

            var emp = new Movie().GetData();

            return Json(emp, JsonRequestBehavior.AllowGet);

        }

               

        [HttpPost]

        public ActionResult PutempDataValue(string cmbvalue)

        {

            Value = cmbvalue;

            var emp = new Movie().PutData(Value);         

            return Json(emp, JsonRequestBehavior.AllowGet);

        }

        //[AcceptVerbs(HttpVerbs.Get)]

        ////[HttpPost]

        //public ActionResult PutData(string cmbvalue)

        //{

        //    var emp = new Movie().PutData(cmbvalue);

        //    return Json(emp, JsonRequestBehavior.AllowGet);

        //}

        public ActionResult About()

        {

            return View();

        }

    }

}

code in model

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Data;

using System.Data.SqlClient;

namespace KendoUIMvcApplication1.Models

{

    public class Movie

    {

        DataTable Datatable = new DataTable();

        DataSet Dataset = new DataSet();

        public List<EmpPro> PutData(string Value)

        {

            string str = "Data Source=SHANKAR-PC\\SQLEXPRESS;Initial Catalog=Occumen;Integrated Security=true";

            SqlConnection connection = new SqlConnection(str);

            SqlCommand command = connection.CreateCommand();

            command.CommandText = "select * from emp where ename='" + Value + "'";

            SqlDataAdapter sda = new SqlDataAdapter();

            sda.SelectCommand = command;

            DataSet ds = new DataSet();

            try

            {

                connection.Open();

                sda.Fill(ds);

                List<EmpPro> objlist = new List<EmpPro>();

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)

                {

                    EmpPro objemp = new EmpPro();

                    objemp.eid = Convert.ToInt32(ds.Tables[0].Rows[i]["eid"]);

                    objemp.ename = ds.Tables[0].Rows[i]["ename"].ToString();

                    objemp.age = Convert.ToInt32(ds.Tables[0].Rows[i]["age"]);

                    objemp.salary = Convert.ToInt64(ds.Tables[0].Rows[i]["salary"]);

                    objlist.Add(objemp);

                }

                //return ds.Tables[0];

                return objlist;

            }

            catch

            {

                return null;

            }

            finally

            {

                if (connection.State != ConnectionState.Closed)

                    connection.Close();

            }

        }

        public List<EmpPro> GetData()

        {

            //string str = "Data Source=(local);Initial Catalog=Student;Persist Security Info=True;Integrated Security=SSPI";

            string str = "Data Source=SHANKAR-PC\\SQLEXPRESS;Initial Catalog=Occumen;Integrated Security=true";

            SqlConnection connection = new SqlConnection(str);

            SqlCommand command = connection.CreateCommand();

            command.CommandText = "select * from emp";

            SqlDataAdapter sda = new SqlDataAdapter();

            sda.SelectCommand = command;

            DataSet ds = new DataSet();

            try

            {

                connection.Open();

                sda.Fill(ds);

                List<EmpPro> objlist = new List<EmpPro>();

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)

                {

                    EmpPro objemp = new EmpPro();

                    objemp.eid = Convert.ToInt32(ds.Tables[0].Rows[i]["eid"]);

                    objemp.ename = ds.Tables[0].Rows[i]["ename"].ToString();

                    objemp.age = Convert.ToInt32(ds.Tables[0].Rows[i]["age"]);

                    objemp.salary = Convert.ToInt64(ds.Tables[0].Rows[i]["salary"]);

                    objlist.Add(objemp);

                }

                //return ds.Tables[0];

                return objlist;

            }

            catch

            {

                return null;

            }

            finally

            {

                if (connection.State != ConnectionState.Closed)

                    connection.Close();

            }

        }

    }

    public class EmpPro

    {

        public int eid { get; set; }

        public string ename { get; set; }

        public int age { set; get; }

        public long salary { set; get; }

    }

}

Alexander Valchev
Telerik team
 answered on 27 Nov 2012
5 answers
226 views
Setting an img to absolute positioning does not work in your editor. I had to resort to jquery ui draggable using the iframeFix property to accomplish this. Is this a bug in your editor or can you provide a way to allow this functionality?
Dustin
Top achievements
Rank 1
 answered on 27 Nov 2012
1 answer
125 views
How would I go about having a grid widget within an accordion widget? is it possible? I'm using something like this


                <ul id="accordion">
                <li class="k-state-active">
                    grid
                    <ul>
                        <li><div id="grid"></div></li>
                    </ul>
                </li>
            </ul>
              

$('#gird).kendoGrid({ ... });
       $("#accordion").kendoPanelBar({ ... });




Dimo
Telerik team
 answered on 27 Nov 2012
0 answers
115 views
Hi,

I want to load a sub grid based on the main grid selected row. But row click event is not at all working.
The grid "Change" event is not occuring when i am selecting the row. Please help me in solving this issue. 

Is there any alternative way to do this..?


Thanks & Regards,
Shalini.
Shalini
Top achievements
Rank 1
 asked on 27 Nov 2012
5 answers
769 views
Hi, how do i add custom inputs (or other things) to the treeview?

I tried doing text ="<input..." but that doesn't work, and I tried just passing back my JSON with an extra param (ie id: 1, text:"...", myparam: "myvalue") and that gave an error.

Here's what I tried:



    $("#treeview").kendoTreeView({
       


        dataSource: [{
        id: 1, text: "<input type='hidden' value='val' />My Documents", expanded: true, spriteCssClass: "rootfolder", items: [
                {
                    id: 2, myparam:2,  text: "Kendo UI Project", expanded: true, spriteCssClass: "folder", items: [
                        { id: 3, text: "about.html", spriteCssClass: "html" },
                        { id: 4, text: "index.html", spriteCssClass: "html" },
                        { id: 5, text: "logo.png", spriteCssClass: "image" }
                    ]
                },
                {
                    id: 6, text: "New Web Site", expanded: true, spriteCssClass: "folder", items: [
                        { id: 7, text: "mockup.jpg", spriteCssClass: "image" },
                        { id: 8, text: "Research.pdf", spriteCssClass: "pdf" },
                    ]
                },
                {
                    id: 9, text: "Reports", expanded: true, spriteCssClass: "folder", items: [
                        { id: 10, text: "February.pdf", spriteCssClass: "pdf" },
                        { id: 11, text: "March.pdf", spriteCssClass: "pdf" },
                        { id: 12, text: "April.pdf", spriteCssClass: "pdf" }
                    ]
                }
            ]
        }]
    });
John
Top achievements
Rank 2
 answered on 27 Nov 2012
2 answers
368 views
Hi!

I want to hide / show one or more tabstrip items in my footers. I have sevaral views in several layouts.

$('.showafterlogin').show() should show all items, but shows only the item in the active view, not in the others.

Is there a way to hide / show all items of all footers? What am i doing wrong?

Thanks, Ralf

<footer data-role="footer">

        <div data-role="tabstrip">

            <a data-icon="home" href="#home">Home</a>

            <a data-icon="globe" href="#standorte">Standorte</a>

            <a class="showafterlogin" data-icon="mostrecent" href="#kundendienst" style="display: none;">Kundendienst</a>

            <a data-icon="camera" href="#scanner">QR-Scanner</a>

            <a data-icon="more" href="#mehr">Mehr</a>

        </div>

    </footer>


Dner
Top achievements
Rank 1
 answered on 27 Nov 2012
0 answers
298 views
Greetings,

I  have a hierarchical grid which supports N levels and I need to add buttons for expand/collapse all the nested grids.
This is the example of my code:

Example

Every time the "Add Expression" button is pressed, a new row is added with a sub-grid and I need to expand/collapse the rows in all the levels.
Please I wonder if someone could help me with this problem, I've been trying many solutions but without good results.
Thanks,


Dorian
Top achievements
Rank 1
 asked on 27 Nov 2012
2 answers
205 views
I'm trying to wrap my head around the data binding feature of kendo. I'm building a mobile app.
I use the following code for my databinding

var app = new kendo.mobile.Application(document.body);
    
    var dayViewModel = kendo.observable(
    {
        todayText: "_",
        showNextDay: function () {
            alert("next");
        },
        showPreviousDay: function () {
            alert("previous");
        }
    });


    kendo.bind($("#dayView"), dayViewModel, kendo.mobile.ui);

As soon as kendo.bind is invoked, the Layout is lost. If the view already has a header element specified, this element is shown instead. Why is this happening?

Also, I've tried a bit further, since the reason why I need to invoke kendo.bind manually, is that I want to load data into the viewModel from a ajax response. I've added the following code for the ajax request

$(function () {
        $.get("request_url", function (data) {
            dayViewModel.todayText = data.DayDescription;
            
            kendo.bind(document.body.children, dayViewModel, kendo.mobile.ui);
        });
    });

And it works just is intended, but I'm still not able to use my Layout. Although I've discovered that if I comment out the first call to kendo.bind, the Layout is applied. Although then the header grows to about double height. And I've got no custom styles or similar.
Allan
Top achievements
Rank 1
 answered on 27 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
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?