Telerik Forums
Kendo UI for jQuery Forum
0 answers
104 views
I thought I'd offer a potential solution to a problem that took me awhile to solve.  Perhaps the Kendo team will consider exposing a method that will make this easier in the future.

I have a search form with a text field and two radio buttons.  The radio buttons are labelled "User ID" and Username."  The user searches for other users in the system by selecting the appropriate criteria by which to search (userid or username) and typing their text in the field.  What I wanted was to provide autocomplete suggestions that pertained to the search criteria.  So if the user has selected Username, the suggestions will be a list of usernames.

Here's how I did it.

JSON pseudo-code of datasource
suggestions: {
   userIds: [],
   userNames: []
}

$(document).ready(function ()
{
    $(":radio").bind('click', setAutoComplete);
    initSuggestions();
}

var initSuggestions = function()
{
    suggestionDS.one('change', function()
    {
          // suggestions is a global variable allowing us to hit
        // this datasource only once.
        suggestions = suggestionDS.data();
        $("#textField").kendoAutoComplete( suggestions.userIds );        
    });
    suggestionDS.read();
}

var setAutoComplete = function()
{    
    // Grab a reference to the autoComplete
    var ac = $("#textField").data("kendoAutoComplete");
    
    // Remove all of its suggestions
    ac.options.dataSource.splice(0, ac.options.dataSource.length);
    
    // Get the correct array based on the user's radio button selection
    var arr = $(":radio:checked").val() == "userIds" ? suggestions.userIds : suggestions.userNames;
    
    // Push all of the elements onto the autocomplete's datasource.
    for( x in arr )
    {
        ac.options.dataSource.push(arr[x]);
    }
}
Sean
Top achievements
Rank 1
 asked on 16 Feb 2012
3 answers
700 views

I have two pages.

The parent: /Main/Home.aspx

The child modal: /Main/MoveJob.aspx

The modal window is a simple form with a Submit button.  The parent opens modal window. When the modal window’s submit button is pressed, the browsers URL is incorrectly redirected to the modal window’s URL.

Parent’s Code is as follows:

     <!-- Define the HTML table, with rows, columns, and data -->
     <table class="jobsGrid">
      <thead>
          <tr>
              <th data-field="title">Job #</th>
              <th data-field="Type">Type of Project</th>
              <th data-field="Desc">Description</th>
              <th data-field="Brand">Brand</th>
              <th data-field="Milestone">Next Milestone</th>
              <th data-field="Location">Job Location</th>
              <th data-field="Sub">Submitter</th>
              <th data-field="move"></th>
          </tr>
      </thead>
      <tbody>
    
          <asp:Repeater ID="Repeater1" runat="server">
            <ItemTemplate>
            <tr>
              <td><%# Eval("JobID")%></td>
              <td><%# Eval("JobTypeName")%></td>
              <td><a href="#"><%# Eval("JobName")%></a></td>
              <td><%# Eval("BrandName")%></td>
              <td>coming soon</td>
              <td><%# Eval("LocationName")%></td>
              <td><%# Eval("SubmitterName")%></td>
              <td><a href="javaScript:;" data-url="../Main/MoveJob.aspx" title="Move Job" class="moveLink" data-id="<%# Eval("JobID")%>">Move</a></td>
            </tr>
            </ItemTemplate>
          </asp:Repeater>
      </tbody>
     </table>
 
        <div class="moveWindow">
        </div>
 
 
 
<script type="text/javascript">
    function refreshGrid() {
        //alert("I will try to refresh the grid");
        var grid = $(".jobsGrid").data("kendoGrid");
        grid.refresh();
    }
 
    //MOVE WINDOW
    $(document).ready(function () {
 
        $(".jobsGrid").kendoGrid();
 
        $(".moveLink").click(function () {
            var id = $(this).data("id");
            var href = $(this).data("url") + "?jobId=" + id;
            var title = $(this).attr("title");
            var myWin = $(".moveWindow");
 
            if (!myWin.data("kendoWindow")) {
                // window not yet initialized
                myWin.kendoWindow({
                    width: "auto",
                    height: "auto",
                    modal: true,
                    resizable: true,
                    title: title,
                    content: href
                });
            } else {
                // reopening window
                myWin.data("kendoWindow")
                .content("Loading...") // add loading message
                .center()
                .refresh(href) // request the URL via AJAX
                .open(); // open the window
 
            }
 
            return false;
        });
    });
 
 
 
 
</script>

Jeremy
Top achievements
Rank 1
 answered on 16 Feb 2012
5 answers
158 views
Hi,

Your site's login is not compatible with www.lastpass.com and that makes the use of your site very inconvenient.  Do you have plans to use something more compatible for your credentials popup?

Thanks!

PS: Using Safari on a Mac with latest LastPass for Safari.
Georgi Tunev
Telerik team
 answered on 16 Feb 2012
6 answers
166 views
Hi!

KendoUI is fantastic, however one problem. I am trying to set a custom template on a column chart for its tooltip, however it seems to be unable to find the fields specified.

Datasource:
var usageData = @Html.Raw(@ServiceStack.Text.JsonSerializer.SerializeToString(Model.ParkingStats));

Code:
$('#chart-utilization').kendoChart({ 
    title: {
        text: "Parking utilization for week"
    },
    dataSource:{
        data: usageData[0].Usage
    },
    series:[{
        type: "column",
        field: "Max",
        name: "Max utilization"
    }],
    categoryAxis:{
        field: "Week"
    },
    tooltip: {
        visible: true,
        template: "${ Max } of ${ Capacity }"
    },
    legend: {
        visible: false
    }
});

The 'Max' and when changed 'Capacity' renders correct columns. But the template can't find either fields and throws a NullReferenceException.


Thanks in advance for your pro-tips ;-) !

Finest regards.
Alexander Valchev
Telerik team
 answered on 16 Feb 2012
0 answers
112 views
Hi,

I would like to know how to display no record not found while using the KENDO grid. Assuming there are not data in the db.

Regards,
Arsene
Top achievements
Rank 1
 asked on 16 Feb 2012
1 answer
161 views
I like behavior of Panel Bar in your demos (http://demos.kendoui.com/web/overview/index.html). Injecting content, persisting selected panelbar item etc. Is there source code? In Kendo download pack is this part of demo simplified.

Thank you.

Zdenek
Kamen Bundev
Telerik team
 answered on 16 Feb 2012
1 answer
325 views
I need to be able to get to the url that is called by the grid after filtering, sorting operations. It would be great if you would expose the url parser that is currently internal so i can use it to save history for browser back operations.
Dimo
Telerik team
 answered on 16 Feb 2012
6 answers
356 views
Hi,

I'm having trouble initializing the menu control from JSON. Using the code from the example:

$(document).ready(function() {
 $("#menu").kendoMenu({
  dataSource: [
   {
    text: "Menu Item 1",
    items: [
     { text: "Sub Menu Item 1" },
     { text: "Sub Menu Item 2" }
    ]
   },
   {
    text: "Menu Item 2"
   }
  ]
 })
});

The menu doesn't show up. I have tried this using <ul id="menu"></ul> as well as <div id="menu"></div> thinking that maybe it had to be an unordered list, but I can't make it work.

When I check the generated page, I can see that there is some kind of attempt to create the menu, but the items from the JSON aren't populated. As seen in web inspector:

<ul id="menu" class="k-widget k-reset k-header k-menu k-menu-horizontal"></ul>
Sameer
Top achievements
Rank 1
 answered on 16 Feb 2012
0 answers
206 views
Using the jQuery plugin: http://www.appelsiini.net/projects/lazyload causes some quirks. If you don't specify a container for the plugin, only the visible images on the screen are loaded, scolling down on a splitter pane shows that any other that were not originally visible are not loaded.

Specify the ID of the pane with the scrollbars + images causes them to all load at once. Changing the pixel threshold does not fix this either.

Has anyone else managed to get images to lazy load with any jQuery plugin with a scrollable splitter pane?
Gabriel
Top achievements
Rank 1
 asked on 16 Feb 2012
1 answer
232 views
Hi

I'm trying to do a DataSource synchronize with the server, like in the Video
"Get Started With The Kendo UI DataSource".
My Forms works correctly, the grid show me the data correctly and I can Update an Delete well.
The problem is when I send the info from inputs to the file that processes. I'm using PHP and I send the info by POST but I don´t receive anything.

Here´s the code for the inputs, is the same that in the video:


 $(document).ready(function() {
                $("#splitter").kendoSplitter();
                
                dataSource = new kendo.data.DataSource ({
                   transport: {
                       read: {
                           url: "data/instituciones.php"
                       },
                       /*create: {
                           url: "data/instituciones.php",
                           type: "PUT"
                       },*/
                       update: {
                           url: "data/prueba.php",
                           type:"POST"
                       },
                       /*destroy:{
                           type:"DELETE"
                       }*/
                   },
                   schema: {
                       data:"data",
                       model: {
                           id:"id_Inst",
                           fields:{
                               nombre:{validation:{required: true}},
                               tipo:{validation:{required: true}}
                           }
                       }
                   }
                });
                
                var selected;
                
                $("#institucion").kendoGrid({
                    dataSource:dataSource,
                    selectable:true,
                    navigable:true,
                    change: function(){
                        var id = this.select().data("id");
                        selected = this.dataSource.get(id);
                        
                        this.dataSource.options.transport.destroy.url = "data/instituciones" + id;
                        this.dataSource.options.transport.update.url = "data/instituciones" + id;
                        
                        $("#cambiarNombre").val(selected.get("nombre"));
                        $("#cambiarTipo").val(selected.get("tipo"));
                    }
                });
                
                $("#crearInst").click(function(){
                    dataSource.add({nombre: $("#nombreInst").val(), tipo: $("#tipoInst").val()});
                    dataSource.sync();
                    
                    $("#nombreInst").val('');
                    $("#tipoInst").val('');
                    dataSource.read();
                });
                
                $("#update").click(function(){
                    selected.set("nombre", $("#cambiarNombre").val());
                    selected.set("tipo", $("#cambiarTipo").val());
                    dataSource.sync();
                });
                
                $("#delete").click(function(){
                    dataSource.remove(selected);
                    dataSource.sync();
                })
            });
        </script>
    </head>
    <body>
        <div id="wrapper">
            <div id="splitter">
                <div id="left">
                    <div class="inner">
                        <h3>Create</h3>
                        <dl>
                            <dt>Nombre:</dt>
                            <dd><input type="text" id="nombreInst" name="nombreInst"></dd>
                            <dt>Tipo:</dt>
                            <dd><input type="text" id="tipoInst" name="tipoInst"></dd>
                            <dd><button id="crearInst">Crear</button></dd>
                        </dl>
                    </div>
                </div>
                <div id="middle">
                    <div id="rigth-top">
                        <div class="inner">
                            <div id="grid">
                                <table id="institucion">
                                    <tr>
                                        <th data-field="nombre">Nombre</th>
                                        <th data-field="tipo">Tipo</th>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="right">
                    <h3>Edit</h3>
                    <dl>
                        <dt>Nombre:</dt>
                        <dd><input  type="text" id="cambiarNombre" name="cambiarNombre"/></dd>
                        <dt>Tipo:</dt>
                        <dd><input  type="text" id="cambiarTipo" name="cambiarTipo"/></dd>
                        <dd><span><button id="update">Actualizar</button><button id="delete">Borrar</button></span></dd>
                    </dl>


And the code used in PHP:

<?php
    
    include 'conexion.php';
    header("Content-type: application/json");
    
    $con = conexion();    
    
    $verb = $_SERVER["REQUEST_METHOD"];
    
    if ($verb == "GET") {
    $data = array();
    $query = pg_query($con, "SELECT * FROM \"Institucion\"");
    
    while ($rows = pg_fetch_object($query)) {
        $data[] = $rows;
    }
    
    
    echo "{\"data\":" .json_encode($data). "}";
    }
    
    if ($verb == "POST") {
        
        $id = $_POST["id_Inst"];
        $nombre = $_POST["cambiarNombre"];
        $tipo = $_POST["cambiarTipo"];
        
        $rs = pg_query($con, "UPDATE \"Institucion\" SET nombre = '$nombre' WHERE id_Inst = ".$id) or die(pg_last_error($con));
        
        echo json_encode($rs);
        
    }

?>

The query runs perfectly but in the field "nombre" I dont receive data so I guess that I have problems sending the info from the inputs maybe in the DataSource I dont know.
Someone can help me?

Thanks a lot,
LHGC
Luis
Top achievements
Rank 1
 answered on 15 Feb 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
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
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?