• .NET Developer Tools DevTools

    UI controls for ASP.NET AJAX, MVC, WPF,
    Silverlight, Windows 8 and Windows Phone

  • Hybrid Mobile Development Icenium

    Cross-platform Mobile Development Tool
    with cloud-based architecture

  • HTML5 / JavaScript Development Kendo UI

    Everything you need to build sites and
    mobile apps with JavaScript and HTML5

  • Testing Tools TestStudio

    One easy tool for Functional, Performance,
    Load and Mobile software testing

  • Web Presence Platform Sitefinity CMS

    Everything for your online business - content
    management, ecommerce, emarketing

  • Agile Project Management TeamPulse

    Simple and intuitive project management
    and collaboration software

Contact us

We are here for you.
  • usa+1‒888‒365‒2779
  • uk+44‒20‒7291‒0580
  • bg+359‒2‒8099850
  • de+49‒89‒2441642‒70
  • au+61‒2‒8090‒1465
  • emailsales@telerik.com
Your account Access to your products, updates and support
Telerik Product Families
  • Your Account
    Your Account
    Log in
  • ABOUT US

    About Telerik

    • Company
    • Press Center
    • Customers
    • Community
    • Careers
    • Contacts
Kendo UI - The way of HTML5
Products ▼
Kendo UI Web Kendo UI Mobile Kendo UI DataViz Server Side Wrappers
Demos Purchase Download
Blogs Documentation
Support ▼
Premium Forums StackOverflow Forums
Resources ▼

Featured Resource

Kendo UI Dojo


Blogs Code Library Demos Documentation FAQ Testing
Premium Forums Roadmap User Voice Videos Webinars More Resources
Contact Us Search
 

Blogs

Kendo UI Quick Answers, #1

Tuesday, September 20, 2011 by Kendo UI Team Blog | Comment 1

As Kendo UI continues to grow in popularity, the Kendo UI community is also quickly growing. And with that growing community come some very good technical questions about Kendo UI. To help give more visibility to some of these questions happening in the active Kendo UI Forums, I will periodically feature a few questions with answers here on the Kendo UI blog.

This is the first installment in "Kendo UI Quick Answers." Let's see what the forum "mailbag" has to offer today.

Q: Why are my Kendo UI input controls not posting values to the server?

Good question. So here is the scenario:

You have a Kendo UI input widget on your page (let's say it's a DropDownList). The Kendo UI widget is inside of an HTML form along with other "plain" form elements. This form contains a submit button that POSTs the form values to a server. In code we have this:

<h2>Basic Form</h2>

<form action="/" method="post">
    <input type="text" id="myText" />
    <input id="myDropList" />
    <input type="submit" value="Submit Form" />
</form>

<script type="text/javascript">
    //Intialize the Kendo UI DropDownList with some options
    $(function () {
        $("#myDropList").kendoDropDownList([
            { text: "Option 1", value:"One" }, 
            { text: "Option 2", value:"Two" }, 
            { text: "Option 3", value:"Three"}]);
    });
</script>

Fill out the form. Click submit. What values will the server receive in the form POST collection?

If you said "NONE!", you are correct. Why?

The solution is in basic HTML forms behavior. While we technically have two input elements in our form, both with an ID attribute, they both lack a Name attribute.  For form input values to be included in a POST, they must have a name attribute.

It's easy to forget this if you're doing a lot of programming with Ajax and JavaScript, where the ID attribute is usually sufficient. In fact, the ID attribute is used for just about everything (JavaScript, CSS) except form POSTing.

Fixing this problem for our "normal" input and our Kendo UI input simply requires the addition of the name attributes, like this:

<form action="/" method="post">
    <input type="text" id="myText" name="myText" />
    <input id="myDropList" name="myDropList" />
    <input type="submit" value="Submit Form" />
</form>

Q: Can I easily customize Kendo UI themes?

Yes, of course! Kendo UI is built to be highly customizable. While current betas only include a few themes out of the box, Kendo UI will eventually provide many "pixel perfect" out-of-the-box themes, along with a visual tool for quick and easy theme customization (similar to jQueryUI's ThemeRoller).

Under the covers, Kendo UI widgets use a semantic CSS convention, sometimes called "CSS Primitives." This means that there are common styles, like ".t-state-hover" (now ".k-state-hover" in upcoming betas) that define hover styles for all Kendo UI widgets.

Kendo UI styles are further broken in to two stylesheets: kendo.common.css and kendo.[themename].css.

The "common" stylesheet has everything needed for "core" Kendo UI widget styling. This stylesheet never needs to be customized. Think of it as "functional" CSS. The second "theme name" stylesheet has the style overrides and definitions specific to each theme. If you want to create a custom theme, it's only this second stylesheet that has to change.

Today, customizing Kendo UI themes is for CSS slingers. For the official release, the Kendo UI Theme Builder will make it possible for anyone to customize a Kendo UI theme.

BONUS: Using LESS to customize a Kendo UI theme

This is rough, not thoroughly tested, and not compatible with post-Beta1 builds of Kendo UI, but I thought I'd share anyway as an example of another way to quickly customize Kendo UI themes. In this case, I've replaced static CSS values in the Kendo UI theme stylesheet with LESS variables. Now, with simple variable changes, I can quickly restyle all of my Kendo UI widgets (obviously, excluding any changes needed in sprite image).

You can grab my LESS-ified theme file from this Gist.

Box of Crayons
image

Green Frog
image

Q: Can I configure Kendo UI JavaScript widgets with server-side code (like PHP)?

Sure. Since Kendo UI is a JavaScript framework, all processing and initialization happen after the HTML and JavaScript get to the browser. If you use a server-side framework, like PHP or ASP.NET, to manipulate the Kendo UI configuration code, these changes will be interpreted when the page loads.

For example, let's say we have some server data we want to use to define the list of options for a Kendo UI DropDownList again. If we were using PHP, we might do something like this to statically embed those options when the page is requested:

<input id="myDropDown" name="myDropDown" />

<script type="text/javascript">
    <?php
    $arr = array("{text:'TX'}","{text:'CA'}","{text:'MA'}");
    $script = 'var newArr = new Array(' . implode(',', $arr) . ')';        
    $echo $script;
    ?>
    
    $(function () {
        $("#myDropList").kendoDropDownList(newArr);
    });
</script>

When the page loads, the DropDownList will initialize with the values rendered in to the JavaScript array created by our PHP code.

In the future, we will start shipping Kendo UI wrappers for various popular server-side frameworks, making server-side configuration even easier. If you want to see a server-wrapper for your preferred framework, be sure to share your idea and vote on the Kendo UI UserVoice site.

---

I suppose that's enough answers for the first installment. Do you have other questions you want to see covered in this format? Let us know in the comments or send me an email directly (todd.anglin@kendoui.com). 'Til next time, have fun with Kendo UI!

About the Author
Todd Anglin is an avid HTML5, CSS3, and JavaScript advocate, and geek about all things web development. He is an active speaker and author, helping developers around the world learn and adopt HTML5. Todd works for Telerik as Chief Evangelist where his current technical focus is on Kendo UI. Todd is @toddanglin on Twitter.

1 Comment

  1. 1 Mahbub 17 May 2013
    I downloaded kendoUI one years ago and used it in my application. I created a custom theme using ThemeBuilder. Today I took the latest version of js and kendo.common.css from Kendo.   My UI is broken in some places. How can I update my  previous kendo.[themename].css  ?

    Do i need to create custom theme everytime while updating kendo js version ?

Comment

  1. Click to add

  2. Click to add

  3. Click to add

  4.    
     
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
     
      
       
Blogs feed
Categories

  • Tutorials (26)
  • Release (33)
  • Browsers (7)
  • Extensions (3)
  • Tip of the Week (10)
  • Videos (5)
  • Concepts and Theory (13)
  • Misc. (25)
  • Framework Constructs (6)
  • Mobile (6)
  • UI Widgets (5)
  • Blogs (1)
Archive
  • 2013 May (8)
  • 2013 April (10)
  • 2013 March (9)
  • 2013 February (12)
  • 2013 January (10)
  • 2012 December (9)
  • 2012 November (11)
  • 2012 October (6)
  • 2012 September (7)
  • 2012 August (8)
  • 2012 July (10)
  • 2012 June (8)
  • 2012 May (10)
  • 2012 April (7)
  • 2012 March (13)
  • 2012 February (10)
  • 2012 January (6)
  • 2011 December (10)
  • 2011 November (4)
  • 2011 October (6)
  • 2011 September (5)
  • 2011 August (9)
Home Web Mobile DataViz Server Wrappers Whitepapers Surveys Chrome Icenium Contact Us

Kendo UI framework is developed by Telerik - a leading provider of UI components for web, desktop and mobile applications. Trusted by over 100,000 customers worldwide for our devotion to quality and industry-best technical support, Telerik helps professionals maximize their productivity and "deliver more than expected" every day.

kendoui - powered by html5, css3 & jquery
get social
  • Twitter
  • Facebook
  • Google plus
  • RSS
Privacy Policy | Branding Guidelines
Powered by Sitefinity CMS

Copyright © 2011 - 2013 Telerik Inc. All rights reserved.