Telerik Forums
Kendo UI for jQuery Forum
6 answers
226 views
Hi
  Is this possible? I've tried a few variations but can't seem to get it working

http://dojo.telerik.com/IWag/2

thanks
Anthony
Top achievements
Rank 1
 answered on 28 Jul 2014
3 answers
144 views
I created a grid using kendo grid that looks like that 

01.<div>
02.    @(Html.Kendo().Grid<MvcApplication2.Areas.Admin.Models.SelfAssessmentModel>()
03.        .Name("grid")
04.        .Columns(columns =>
05.        {
06.            columns.Bound(c => c.QuestionSortOrder).Width(40);
07.            columns.Bound(c => c.ModuleName).Width(100);
08.            columns.Bound(c => c.QuestionText).Width(300); ;
09.            columns.Bound(c => c.QuestionGraded).Template(@<text>@((bool)item.QuestionGraded?"Yes":"No")</text>).ClientTemplate(@"#=QuestionGraded ? 'Yes' : 'No' #"); ;
10.            columns.Bound(c => c.QuestionAnswerTypeName);
11.            columns.Bound(c => c.PartName);
12.            columns.Command(cmd => cmd.Edit());
13.             
14.        })
15.        .DataSource(dataSource => dataSource
16.        .Ajax()
17.        .PageSize(20)
18.        .Model(model =>{ model.Id(m => m.QuestionID);})
19.        .Read(read => read.Action("Editing_ReadSelf", "SelfAssesmentAdmin", new {id =1}))
20.        .Update(up => up.Action("Editing_UpdateSelf", "SelfAssesmentAdmin"))
21.        )
22.       .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("SelfAssesmentEditor").Window( w => w.Width(700)))
23.       .Pageable()
24.       .Sortable()
25.        )
26.</div>

I also use a "SelfAssesmentEditor" Template that looks like that 

01.@model MvcApplication2.Areas.Admin.Models.SelfAssessmentModel
02.@{
03.    Layout = null;
04.}
05.<style>
06.    .selftable
07.    {
08.        margin-left:40px;
09.        width:600px;
10.    }
11..selftable, td
12.{
13.    height:70px;
14.}
15.    #QuestionText
16.    { width:300px;
17.      height:100px;
18.    }
19.</style>
20. 
21.<table class="selftable">
22.    <tr>
23.        <td>Question Sort Order</td>
24.        <td>@Html.TextBoxFor(model=>model.QuestionSortOrder)</td>
25.    </tr>
26.      <tr>
27.        <td>Question</td>
28.        <td>@Html.TextAreaFor(model=>model.QuestionText)<br /></td>
29.    </tr>
30.    <tr>
31.        <td>Question Graded</td>
32.        <td valign="center">    <label>@Html.RadioButtonFor(model =>model.QuestionGraded ,  "true" )  Yes</label>
33.                    <label>@Html.RadioButtonFor(model => model.QuestionGraded,  "false")  No</label></td>
34.    </tr>
35.    <tr>
36.        <td>Number of Correct Responses</td>
37.        <td>@Html.TextBoxFor(model=>model.NumberOfCorrectResponses)</td>
38.    </tr>
39.    <tr>
40.        <td>Part</td>
41.        <td>@Html.DropDownListFor(x =>x.PartID,   (SelectList)ViewBag.Partlist)</td>
42.    </tr>
43.    <tr>
44.        <td>Question Answe Type</td>
45.        <td>@Html.DropDownListFor(x =>x.QuestionAnswerTypeID,   (SelectList)ViewBag.QuestionAnswerTypelist)</td>
46.    </tr>
47.</table>

I am now trying to inset a kendo MVVM inside my template but it not working, it does works on the same page as grid just not on the same page editor template here is my MVVM
01.<div id="peopleList">
02.    <div id="commands">
03.        <button data-bind="click: add" class="k-button">Add</button>
04.    </div>
05. 
06.    <table>
07.    <thead>
08.        <tr>
09.            <th>First Name</th>
10.            <th>Last Name</th>
11.            <th>Full Name</th>
12.            <th></th>
13.        </tr>
14.    </thead>
15.    <tbody data-bind="source: people" data-template="personTemplate">
16.    </tbody>  
17.    </table>
18.</div>
19. 
20.<script type="text/x-kendo-template" id="personTemplate">
21.    <tr>
22.        <td><input data-bind="value: firstName" /></td>
23.        <td><input data-bind="value: lastName" /></td>
24.        <td><span data-bind="text: fullName" /></td>
25.        <td><button class="k-button" data-bind="click: delete">X</button></td>
26.    </tr>
27.</script>
28. 
29.<script type="text/javascript">
30. 
31.    // Define a Person model.
32.    var Person = kendo.data.Model.define({
33.        fields: {
34.            "firstName": {
35.                type: "string"
36.            },
37.            "lastName": {
38.                type: "string"
39.            }
40.        },
41. 
42.        // Define a function for fullName to get the firstName and lastName
43.        // and concatenate them together.
44.        fullName: function () {
45.            return this.get("firstName") + " " + this.get("lastName");
46.        }
47.    });
48. 
49.    // Create an observable object with an obserable array where each item
50.    // in the array is an instance of a Person model.
51.    var vm = kendo.observable({
52.        people: [
53.            new Person({
54.                firstName: "",
55.                lastName: ""
56.            })
57.        ],
58. 
59.        // Add a new person to the array.
60.        add: function () {
61.            this.people.push(new Person());
62.        },
63. 
64.        // Delete the person from the array.
65.        delete: function (e) {
66.            var that = this;
67.            $.each(that.people, function (idx, person) {
68.                if (e.data.uid === person.uid) {
69.                    that.people.splice(idx, 1);
70.                    return true;
71.                }
72.            });
73.        }
74.    });
75. 
76.    kendo.bind($("#peopleList"), vm);
77.    </script>
Can Anyone please help me on how to run kendo MVVM from the editor template of the grid. 

Thank you. 





Alexander Popov
Telerik team
 answered on 28 Jul 2014
3 answers
1.3K+ views
I am currently working on a Web page which is built dynamically, not only on the initial page load, but also updating the page via REST-based service calls which return HTML fragments (containing their own "data-bind" tags) as well as portions of JavaScript meant to augment the observable object.

I have a simple ViewModel which looks like the following:

var viewModel = kendo.observable({ name: "Test", html: "" });


Inside the Web page, I have both an <input> element and a <div> element (acting as a placeholder) which looks like something below:

<div id="mainView">
   <input type="text" data-bind="value: name" />
   <div data-bind="html: html"></div>
</div>


In the JavaScript, the view is correctly bound in my $(document).read() :

kendo.bind($("#mainView"), viewModel);


Now, I make a REST-based service call which return the following fragment (as variable 'htmlFragment'):

<input type="text" data-bind="value: name" />

I then set the 'html' member of my ViewModel:  

viewModel.set("html", htmlFragment);

I am seeing the following occur: a) The text box appears with the value "Test"; and b) after the service call, a new text box appears, but without any data.  Now, changing the text box originally rendered will update the ViewModel, but the second text box will not.  The HTML (with the same binding as the first generated text box) is injected into the DOM with the correct data-bind tag, but no binding occurs on the element.

For lack of any other methods I decided to again call kendo.bind($("#mainView"), viewModel) after the service call and after the HTML injection and it then apparently binds correctly and now both text boxes are synchronized.  All of that being said, here are my questions:

a) Is there inherently anything wrong with calling the kendo.bind() method multiple times if either the ViewModel and/or DOM are augmented with new members/bindings?
b) Is there any way to 'refresh' the bindings without calling bind() again (as I don't know how other UI elements will behave yet)?
c) Is it possible to hook the change event (not specifically for a particular named binding, but for a binding type (i.e. "html" binding) and just refresh the bindings for that particular HTML fragment?

Any information or suggestions would be greatly appreciated, thank you!
Petyo
Telerik team
 answered on 28 Jul 2014
1 answer
210 views
I have an application with a form in which i have a inline-editor where i can create a html -page. The problem is that i can't put a <form> code in this editor-html, because this is overruled by the parent form. I use the top-form to submit all the information to the server.

I have a sample here : http://jsbin.com/yutugipi/1/edit

In this sample i can't place (in the html-editor) the html-string : <form></form>
If i remove in the source code the <form> definition (so the editor is no longer part of a form), it works fine.

I hope you can solve this problem

Regards,
Ivor
Georgi Krustev
Telerik team
 answered on 28 Jul 2014
1 answer
245 views
It seems like the event.action "add" is a bit different from the "itemchange". The "itemchange" event does what it should do but the "add" only inserts the values and the change routine is not fired, is there a way to fire the "itemchange" after an "add" to update the row ?
Alexander Popov
Telerik team
 answered on 28 Jul 2014
1 answer
236 views
Hi All,

I have a textbox inside template which i want to display on Kendo Popup, everything is working except validation. 

 <script type="text/x-kendo-template" id="popup-template">
     <div>
           @Html.TextBoxFor(m => m.Address)
        </div>
</script>

which will render below html tag for textbox 

<input class="k-textbox" data-val="true" data-val-length="Address  must have a length between 1 and 100 characters." data-val-length-max="100" data-val-length-min="1" data-val-regex="Address must only contain alpha-numeric characters." data-val-regex-pattern="^[A-Za-z\d]*$" id="Address " name="Address " placeholder="Type Address " type="text" value="">

Any specific reason why validation is not working here. Please correct me if I am doing anything wrong here.

Thanks-

Alexander Popov
Telerik team
 answered on 28 Jul 2014
1 answer
254 views
Hi All,

I have a textbox inside template, which I want t display on Kendo Popup. Everything is working fine except Validation 

here is Template code:

  <script type="text/x-kendo-template" id="popup-template">
     <div>
   @Html.TextBoxFor(m => m.Address)
        </div>
</script>

here is html render for Textbox :
<input class="k-textbox" data-val="true" data-val-length="Address must have a length between 1 and 200 characters." data-val-length-max="200" data-val-length-min="1" data-val-regex="Address must only contain alpha-numeric characters." data-val-regex-pattern="^[A-Za-z\d]*$" id="Address" name="Address" placeholder="Type Address" type="text" value="">

Any specific reason why validation is not working here. please correct me if I am doing anything wrong.

Thanks-
Alexander Popov
Telerik team
 answered on 28 Jul 2014
1 answer
99 views
I am manually adding an object to the dataSouce property of the grid. As expect the item is added. The types of the fields include dates. The dates are not rendering propertly when they are manually added to the grid. 

/Date(1406185200000)/

This is obviously not the look I want in the columns. Can you let me know the best way to format the dates(hopefully by configuration). 

Thanks
Vladimir Iliev
Telerik team
 answered on 28 Jul 2014
2 answers
2.9K+ views
I have a kendo grid bound to a data source. I need to display a radio button column for the Primary key in the datasource. 

My Datasource looks something like this

CountryID ,CountryName

1 , SomeCountryName1
2 , SomeCountryName2

Model

public class Country
    {
        public Country()
        {
        }

        public int CountryID { get; set; }
        public string CountryName { get; set; }
    }

What is the right way of adding a radio button client template to the CountryID column. Also i need to obtain the selected Country ID 
I managed to get the radio buttons but they don't seem to be working the way i want it to.

I need to get it working something like this.

The selection of radio button should highlight a single row and give back the ID 


@(Html.Kendo().Grid<Mvc4SampleApplication.Models.Country>()
    .Name("CountriesGrid2")
    .EnableCustomBinding(true) // Enable custom binding
        .Pageable(pager => pager
        .PageSizes(true))
    .Columns(columns =>
    {
        columns.Bound(o => o.CountryID).Width(200).ClientTemplate("<input type='radio' name='CountryID' value='#= CountryID #'  />").Title("Select Country").HtmlAttributes(new { style = "text-align:center" });  
              columns.Bound(o => o.CountryName);

    })
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .Read(read => read.Action("Index2", "Address").Type(HttpVerbs.Get))
                        .Model(model =>
                        {

                            //The unique identifier (primary key) of the model is the ProductID property
                            model.Id(country => country.CountryID);

                            // Declare a model field and optionally specify its default value (used when a new model instance is created)
                            model.Field(country => country.CountryName).DefaultValue("N/A");

                            // Declare a model field and make it readonly

                        })
                    ).Pageable(pager => pager
                        .PageSizes(true)).Sortable().Scrollable()
                            .Selectable(selectable => selectable.Enabled(true)
             .Mode(GridSelectionMode.Single)
                       .Type(GridSelectionType.Row)).Events(events => events.Change(@<text>
                function(e) {
                //event handling code
                   
                    alert("Hello");
                }
                </text>)))

 

Amyth
Top achievements
Rank 1
 answered on 27 Jul 2014
8 answers
944 views
Hello All,

I am working on customizing the MultiSelect to function a little differently for a slightly older (less Facebook savvy) crowd. I am trying to duplicate the functionality of the following jQuery plugin:
http://www.erichynds.com/examples/jquery-multiselect/examples.htm

Note, the check all / uncheck all is not necessary... I basically want to show the list of check-boxes next to each item, giving a visual indication that items can be toggled on and off.

Adding the check-boxes is a simple task accomplished via templates, and keeping the list open is easy with autoClose: false... but I have a few problems...
  1. When an item is selected, it is removed from the list.  I can't find any documentation on how to prevent this
  2. Once issue 1 is taken care of, I need to check the check-box and make a second click of the list item deselect said item.  I assume some function bound to the select event will be needed to accomplish this, but I'm not that far along yet.
  3. Once 1 & 2 are complete, I will need to pre-select the checkboxes.  I am likely going to jump to an MVVM model for this functionality, but I was trying to keep this simple until I had a proof of concept that the Kendo controls could do what I need.
Here is where I'm at so far:
http://jsbin.com/reluti/2/edit?html,js,output

Doe anyone have any insight on the two issues above?

Thanks,
James Carpenter
Jim
Top achievements
Rank 2
 answered on 27 Jul 2014
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
Drag and Drop
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
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
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?