Telerik Forums
Kendo UI for jQuery Forum
1 answer
86 views
Hi,

I am using KendoUI version Q2 2012.
I have added a drpdownlist. I set its SelectedIndex to -1.But when I open a dropdown list it is selecting 0 index by default.
I want to reset selection after every selection.
Following is my code:

@(Html.Kendo().DropDownList()
                                  .Name("BorderWidth")
                                  .HtmlAttributes(new { style = "width: 0px;float:left;" })
                                  .DataTextField("Text")
                                  .DataValueField("Value")
                                  .SelectedIndex(-1)
                                  .Height(150)
                                          .Events(events => events
                                                      .Close("borderWidthChange")
                                                 )
                                  .BindTo(new List<SelectListItem>() {
                                      new SelectListItem() {
                                        Text = "1pt", Value = "1"   
                                      },
                                       new SelectListItem() {
                                        Text = "2pt", Value = "2"   
                                      },
                                       new SelectListItem() {
                                        Text = "3pt", Value = "3"   
                                      },
                                       new SelectListItem() {
                                        Text = "4pt", Value = "4"   
                                      },
                                       new SelectListItem() {
                                        Text = "5pt", Value = "5"   
                                      },
                                       new SelectListItem() {
                                        Text = "6pt", Value = "6"   
                                      }
                                  })
                                
.Template("${ data.Text } " + "<img src=\"" +
Url.Content("~/Content/Images/Line/") + "${data.Text}.png\" />")

                            )

Kindly help.
Petur Subev
Telerik team
 answered on 02 Oct 2013
5 answers
343 views
Hi,

I am trying to specify a value with the menu item when I add it to the menu. When I inspect the menu.dataSource I can see the value I specified during initialization, however I don't see a way to associate the select event's e.item object to the menu.dataSource[N] object that the li was created from.

My goal is to store a value with each menu item that is NOT the text of the menu.

Any guidance is appreciated.

Thanks,

Elan
Kamen Bundev
Telerik team
 answered on 02 Oct 2013
3 answers
297 views
I have two grids on a scrolling div.
<div>
    <table id="grid1">
    ...
    </table>
 
    <table id="grid2">
    ...
    </table>
</div>
 
<script>
  $(document).ready(function() {
    $("#grid1").kendoGrid({
      height: 200,
      scrollable: false
    });
 
    $("#grid2").kendoGrid({
      height: 200,
      scrollable: false
    });
 
  });
</script>
Each div is initialized via tables using the standard grid.KendoGrid({...}) method; however, only one of the grids is styled correctly.
What is missing or otherwise causing the style to fail?  Thanks

I am prototyping this in the following jsFiddle:  http://jsfiddle.net/raltman/wcD28/13/

Dimo
Telerik team
 answered on 02 Oct 2013
3 answers
300 views
I have a grid, approx 500 row in it, using remote data.  The grid is declared in MVC helper, rather than JS, but I don't think that matters in for this issue.

I've added a function which updates some of the values within the grid, that works fine:

//I have already tried using grid.dataSource.data() instead of view(), but it doesn't help)
var dataItems = grid.dataSource.view();
 
for (i = 0; i < dataItems.length; i++) {
var dataItem = dataItems[i];
dataItem.Amount = dataItem.OriginalAmount;
dataItem.IsIncluded = true;
 
dataItem.dirty = true;
}
 
grid.dataSource.fetch();   //This shows the dataSource's changed values in the grid

(I deliberately am not using the dataItem.set() method, because it fires the dataSource.change event repeatedly, which makes the js function bomb out if running on many rows.

So the above function works fine, and updates 500 rows in about half a second, which is acceptable.  

The problem comes when I want to save (sync) the changes.  It takes an age, close to a minute before it even calls the controller action to update (as specified for update in the grid definition).

It does work and save/update, but it needs to be faster.  

Is there a way that doesn't take a minute to hit the controller save/update action?  Or is there a better way of doing this?

Thanks.
Atanas Korchev
Telerik team
 answered on 02 Oct 2013
4 answers
776 views
Hi

I have a TabStrip control on my page but I would like to bind each tab to a separate page as opposed to put all the views in the same page:
<div data-role="footer">
    <div data-role="tabstrip">
        <a href="/Clients" data-icon="contacts">Clients</a>
        <a href="/Home" data-icon="organize">Tickets</a>
        <a href="/Settings" data-icon="settings">Settings</a>
    </div>
</div>
But when I click on the tabs I see strange URL results. For example if I am in <domain>/Clients page and click on Home the URL that is generated will be <domain>/Clients#/Home instead of <domain>/Home.

Could you let me know what I am doing wrong?

Thanks in advance
Ron Farko

Kiril Nikolov
Telerik team
 answered on 02 Oct 2013
2 answers
232 views
I am using Kendo UI Web Grid, not one of the Server Wrappers. I am only displaying a few fields in the grid.
The rest of the fields are displayed in the create or edit popup. For this popup I am using a template:

<script id="popup_editor" type="text/x-kendo-template">
<div class="k-edit-label">
<label for="Title">Title</label>
</div>
<div class="k-edit-field">
<input type="text" class="k-input k-textbox" name="Title" data-bind="value:Title" required>
</div>
</script>

and then I am calling it from the grid:
 editable: {
mode: "popup",
template: $("#popup_editor").html(),
confirmation: "Are you sure?"
}

This works great for input boxes. However I have a foreign key column in my table. I want to display all the options from the foreign key table in a dropdown and select the correct one based on the value in my table. I have searched around quite a bit but haven't been able to find an answer or example to this.

Any help would be greatly appreciated.
Joel
Top achievements
Rank 2
 answered on 01 Oct 2013
1 answer
190 views
I am trying to figure out how to get a date column to sort when the grid was initialized from an html table. I see from the demos that I would have added formatting to the columns, but I don't see how to add the format when initializing from HTML.

Some things to take into consideration in trying to answert this question:

The size of the table, and number of columns, is created dynamically in a JSP using jstl. This means that a row might be date, and it might not be.

The formatting of the date is always "ddMMMyyyy", all upper case.

Here is an example of what the html might look like:
<tr>
    <td><div>01JAN2013</div></td>
</tr>

Notice that it has a div in it, which is used for cell scrolling, should the value not be a date, and have large amounts of text in it.

The jstl for the header of the date might be something like this:

<c:forEach var="column" items="${row}">
<c:choose>
    <c:when test="${column.type eq "date"}" >
        <th <%---Add some kind fo attribute here to tell kendo this is a date?---%>My Date</th>
     </c:when>
     <c:otherwise>
         <%-- Do some other stuff, without date formatting --%>
     </c:otherwise>
 </c:choose>
</c:forEach>

I suppose I could try to build the JavaScript object dynamically, but I really dislike the idea of building JavaScript objects with jstl, and I'm not certain how that might conflict with initializing from html.

I'm working with some legacy data and services, and so I have no choice as to how the data is returned to the JSP. 


Alexander Valchev
Telerik team
 answered on 01 Oct 2013
1 answer
196 views
I'm not sure if I'm posting in the right place....

We're using KendoUI MVC with the help wrappers.

I have a simple page created in MVC using KendoUI.

The controller sets the value of a global variable "SomeValue" on initialization, but what I don't understand is when I use AJAX binding to bind data from the controller to the grid, why when "GetData()" is called it is unable to see the value of "SomeValue" or even the value of ViewBag.Heading.

When GetData() is called its almost as if the function is being called in isolation and doesn't know anything about the anything else in the controller....

What I wanted to do was when the Index controller is called, load all my data from my database into a global variable, so when "GetData()" is called it doesn't have to reload the data from the database, it can use the data that is set to the variable "SomeValue"....

How do you do this in KendoUI?

Here is a snippet of code of what I'm trying to do....


Controller
--------------
public string SomeValue;

public ActionResult Index(string strClient, string strProductType, string strCloseOfBusinessDate)
{
    ViewBag.Heading = "DV01";

    SomeValue = "Hello there!";

    return View();
}

public ActionResult GetData(string strClientName, string strDate)
{
    return Json(Graph.GraphData(SomeValue, strClientName, strDate));
}

Petur Subev
Telerik team
 answered on 01 Oct 2013
10 answers
2.0K+ views
Hi,

I have a Telerik MVC Combobox which I'm trying to migrate it to Kendo. The original code looked like :

@(Html.Telerik().ComboBox().Name("CbPlants")
    .BindTo(new SelectList(Model.PowerPlants, "Key", "Value", Model.SelectedPowerPlant))
    .Filterable(filter => filter.FilterMode(AutoCompleteFilterMode.Contains))
    .ClientEvents(c => c.OnChange("OnCbPlantsChange"))
    .AutoFill(true))
         
After migration as per the instructions, it looks like :
           
@(Html.Kendo().ComboBox().Name("CbPlants")
       .BindTo(new SelectList(Model.PowerPlants, "Key", "Value", Model.SelectedPowerPlant))
      .DataTextField("Text")
      .DataValueField("Value")
      .Filter(FilterType.Contains)
      .Events(c => c.Change("OnCbPlantsChange"))
      .Suggest(true))


The combobox is bound to a list of powerplants, whose key is a guid. I pass both the list as well as the selected item in the binding.              
It works well except for the fact that, when the page is refreshed, I see the selected item's guid for sometime, before the correct value is displayed. Please have a look at the attached pic.

Maybe it's because of the time taken for the combobox to load. Can I suppress displaying the key till the list loads ?

I tried setting the selected item in the DataBound event, instead of the razor. That seems to work. But unfortunately, the filtering & auto fill feature doesn't then. Is there any other way to achieve what I could do with the old MVC extensions ?

Regards

Achilles
Achilles
Top achievements
Rank 1
 answered on 01 Oct 2013
1 answer
60 views
$("#stock-chart").kendoStockChart({
                   dataSource: {
                       data: incomeData
                   },
                   title: {
                       text: showName
                   },
                   dateField: "Date",
                   seriesDefaults: {
                       type: "area",
                   },
                   series:
                   [{
                       field: "Open",
                       name: "1",
 
                       color:"blue"
                   }, {
                       field: "High",
                       name: "2",
 
                       color: "green"
                   }, {
                       field: "Low",
                       name: "3",
 
                       color: "black"
                   }],
                   navigator: {
                       series: {
                           type: "area",
                           field: "Open"
                       }
                   },
                   legend: {
                       position: "bottom",
                       visible: true,
                   },
               });
           }
           $(document).ready(createChart);
           $(document).bind("kendo:skinChange", createChart);

Code works perfectly. The problem is that everytime when i hover over legend it appears in firebug that n is null. I specify that i don't have any problem with the script just it appears in firebug that n is null. My question is why? I have a problem or is from the Kendo Ui? Please if you can help it would be great.

P.S Sorry for my English is not my main language.
 
T. Tsonev
Telerik team
 answered on 01 Oct 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?