This is a migrated thread and some comments may be shown as answers.

Newbie questions & problems

3 Answers 161 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
sebastian
Top achievements
Rank 1
sebastian asked on 26 Oct 2011, 01:16 PM
Hello everyone,

     
      i am trying to add data from queries performed in php/mysql and return the data in within datasource, or maybe even other components of kendo UI. it was pretty easy to do a combo box fill in. however......

could i get help with that here?
I am currently cacthing up on ajax and other jquery functions and concepts, such that i am not "completely" naked on the subject.

all help is appreciated .

sebs.-

3 Answers, 1 is accepted

Sort by
0
sebastian
Top achievements
Rank 1
answered on 26 Oct 2011, 05:13 PM
hey people,

i figured i would do a php/sql query , hold the results in a php variable and pass it on to the data variable on dataSource, correctly formatted.

however i cannot get datasource going, even with the code copied from the demo.
can someone point out to me why im currently getting no data in my rows, i only got the <th> showing in orange with no data.

here is the plagiarized code:

01.<body>
02.        <div id="example" class="k-content">
03.            <table id="clientela">
04.                <thead>
05.                    <tr>
06.                        <th>Client_ID</th>
07.                        <th>Razon_Social</th>
08.                    </tr>
09.                </thead>
10.                <tbody>
11.                    <tr>
12.                        <td colspan="4"></td>
13.                    </tr>
14.                </tbody>
15.            </table>
16. 
17.<script id="template" type="text/x-kendo-template">
18.                <tr>
19.                    <td>#= Client_ID #</td>
20.                    <td>#= Razon_Social #</td>
21.                </tr>
22.</script>
23.<script>
24. $(document).ready(function() {
25.                    // create a template using the above definition
26.                    var template = kendo.template($("#template").html());
27. 
28.var clientes = [ { "Client_ID": 1, "Razon_Social": default } ];
29. 
30.var dataSource = new kendo.data.DataSource({
31.data: clientes,
32.change: function() { // subscribe to the CHANGE event of the data source
33.   $("#clientela tbody").html(kendo.render(template, this.view())); // populate the table
34.                        }
35.                });
36.         dataSource.read();
37.                });
38.</script>
39. 
40.            <style scoped>
41.                #clientela {
42.                    border-collapse: separate;
43.                    border-spacing: 0;
44.                }
45. 
46.                #clientela th {
47.                    background-color: #ef652a;
48.                    padding: 9px 6px;
49.                    color: #fff;
50.                    text-align: left;
51.                    line-height: 14px;
52.                    border-width: 1px;
53.                    border-style: solid;
54.                    border-color: #d75b26 #d75b26 #d75b26 #f28455;
55.                }
56. 
57.                #clientela td {
58.                    line-height: 23px;
59.                    padding: 0 6px;
60.                    background: #eaeaea;
61.                    color: #3d3d3d;
62.                    border-width: 1px;
63.                    border-style: solid;
64.                    border-color: #f4f4f4 #d6d6d6 #d6d6d6 #f4f4f4;
65.                }
66.            </style>
67.        </div>
68. 
69.</body>



0
Atanas Korchev
Telerik team
answered on 27 Oct 2011, 09:09 AM
Hello Sebastian,

 This is not valid JavaScript:

var clientes = [ { "Client_ID": 1, "Razon_Social": default } ];

because default is a JavaScript keyword. If this is supposed to be a string add quotes:

var clientes = [ { "Client_ID": 1, "Razon_Social": "default" } ];

All the best,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sebastian
Top achievements
Rank 1
answered on 27 Oct 2011, 07:02 PM
thanks a lot Atanas, it was getting painful over here.
i´ve already applied it to my queries.

phew...
Tags
Data Source
Asked by
sebastian
Top achievements
Rank 1
Answers by
sebastian
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or