jQWidgets Forums
Forum Replies Created
-
Author
-
October 2, 2014 at 8:36 pm in reply to: Binding jqxDataTable to Remote data Binding jqxDataTable to Remote data #60550
I solved the problem like this (create 5 different divs in the container)
data.php<?php header('Content-Type: text/javascript; charset=utf8'); include('connect.php'); //connection String $db = new mysqli($hostname, $username, $password, $database); // get data and store in a json array $query = "SELECT * FROM DEV_OBJEKT ORDER BY OBJ_NR DESC "; $from = 0; $to = 26; $query .= "LIMIT ".$from.",".$to; $result=$db->query($query); $result->data_seek(0); $i=1; while($row = $result->fetch_assoc()) { $arrbild[$i]=$row['OBJ_NR']."_1.JPG"; $arrnr[$i]=$row['OBJ_NR']; $arrobj[$i]=$row['OBJ']; $arrut[$i]=$row['UTROP']; $arrbud[$i]=$row['BUD']; $arrst[$i]=$row['STOPPTID']; $i++; if($i==6) { $i=1; $objekt[] = array( 'Bild1' => utf8_encode($arrbild[1]), 'Nr1' => $arrnr[1], 'Obj1' => utf8_encode($arrobj[1]), 'Ut1' => $arrut[1], 'Bud1' => $arrbud[1], 'St1' => $arrst[1], 'Bild2' => $arrbild[2], 'Nr2' => $arrnr[2], 'Obj2' => utf8_encode($arrobj[2]), 'Ut2' => $arrut[2], 'Bud2' => $arrbud[2], 'St2' => $arrst[2], 'Bild3' => $arrbild[3], 'Nr3' => $arrnr[3], 'Obj3' => utf8_encode($arrobj[3]), 'Ut3' => $arrut[3], 'Bud3' => $arrbud[3], 'St3' => $arrst[3], 'Bild4' => $arrbild[4], 'Nr4' => $arrnr[4], 'Obj4' => utf8_encode($arrobj[4]), 'Ut4' => $arrut[4], 'Bud4' => $arrbud[4], 'St4' => $arrst[4], 'Bild5' => $arrbild[5], 'Nr5' => $arrnr[5], 'Obj5' => utf8_encode($arrobj[5]), 'Ut5' => $arrut[5], 'Bud5' => $arrbud[5], 'St5' => $arrst[5] ); } } echo json_encode($objekt); ?> demo
$(document).ready(function () {
var source =
{
datatype: “json”,
datafields: [
{ name: ‘Bild1’, type: ‘string’},
{ name: ‘Nr1’, type: ‘string’},
{ name: ‘Obj1’, type: ‘string’},
{ name: ‘Ut1’, type: ‘string’},
{ name: ‘Bud1’, type: ‘string’},
{ name: ‘St1’, type: ‘string’},
{ name: ‘Bild2’, type: ‘string’},
{ name: ‘Nr2’, type: ‘string’},
{ name: ‘Obj2’, type: ‘string’},
{ name: ‘Ut2’, type: ‘string’},
{ name: ‘Bud2’, type: ‘string’},
{ name: ‘St2’, type: ‘string’},
{ name: ‘Bild3’, type: ‘string’},
{ name: ‘Nr3’, type: ‘string’},
{ name: ‘Obj3’, type: ‘string’},
{ name: ‘Ut3’, type: ‘string’},
{ name: ‘Bud3’, type: ‘string’},
{ name: ‘St3’, type: ‘string’},
{ name: ‘Bild4’, type: ‘string’},
{ name: ‘Nr4’, type: ‘string’},
{ name: ‘Obj4’, type: ‘string’},
{ name: ‘Ut4’, type: ‘string’},
{ name: ‘Bud4’, type: ‘string’},
{ name: ‘St4’, type: ‘string’},
{ name: ‘Bild5’, type: ‘string’},
{ name: ‘Nr5’, type: ‘string’},
{ name: ‘Obj5’, type: ‘string’},
{ name: ‘Ut5’, type: ‘string’},
{ name: ‘Bud5’, type: ‘string’},
{ name: ‘St5’, type: ‘string’}
],
url: ‘data.php’,
cache: false
};
var dataAdapter = new $.jqx.dataAdapter(source);October 1, 2014 at 9:47 am in reply to: Binding jqxDataTable to Remote data Binding jqxDataTable to Remote data #60443And if I change the loop I only got one container/column in each row
October 1, 2014 at 9:43 am in reply to: Binding jqxDataTable to Remote data Binding jqxDataTable to Remote data #60442How can I access each data in rowData ? I get the same data four times before I get the next.
October 1, 2014 at 8:55 am in reply to: Binding jqxDataTable to Remote data Binding jqxDataTable to Remote data #60433`<?php
#Include the connect.php file
include(‘connect.php’);
#Connect to the database
//connection String
$connect = mysql_connect($hostname, $username, $password)
or die(‘Could not connect: ‘ . mysql_error());
//select database
mysql_select_db($database, $connect);
//Select The database
$bool = mysql_select_db($database, $connect);
if ($bool === False){
print “can’t find $database”;
}
// get data and store in a json array
$query = “SELECT * FROM Customers”;
$from = 0;
$to = 30;
$query .= ” LIMIT “.$from.”,”.$to;$result = mysql_query($query) or die(“SQL Error 1: ” . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$customers[] = array(
‘CompanyName’ => $row[‘CompanyName’],
‘ContactName’ => $row[‘ContactName’],
‘ContactTitle’ => $row[‘ContactTitle’],
‘Address’ => $row[‘Address’],
‘City’ => $row[‘City’]
);
}echo json_encode($customers);
?>Sorry forgot Code
October 1, 2014 at 8:50 am in reply to: Binding jqxDataTable to Remote data Binding jqxDataTable to Remote data #60432Hi !
I’m using Northwind as in your demo.<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" media="screen" /> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.arctic.css" media="screen" /> <link rel="stylesheet" href="../../styles/jqx.apireference.css" media="screen" /> <link rel="stylesheet" href="../../styles/site.css" media="screen" /> <script type="text/javascript" src="../../scripts/format.js"></script> <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="../../scripts/demos.js"></script> <script type="text/javascript" src="../../scripts/demofunctions.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxtabs.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdatatable.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxresponse.js"></script> <script type="text/javascript"> $(document).ready(function () { var source = { datatype: "json", datafields: [ { name: 'CompanyName', type: 'string'}, { name: 'ContactName', type: 'string'}, { name: 'ContactTitle', type: 'string'}, { name: 'Address', type: 'string'}, { name: 'City', type: 'string'} ], url: 'data.php', cache: false }; var dataAdapter = new $.jqx.dataAdapter(source); var itemsInCart = 0; $("#dataTable").jqxDataTable( { width: 860, source: dataAdapter, sortable: true, pageable: true, pageSize: 3, theme: 'arctic', pagerButtonsCount: 5, enableHover: false, selectionMode: 'none', rendered: function () { $(".buy").jqxButton({ theme: 'arctic' }); $(".buy").click(function () { itemsInCart++; $(".cart-top p").html(itemsInCart + " products"); }); }, columns: [ { text: 'Products', align: 'left', dataField: 'model', // row - row's index. // column - column's data field. // value - cell's value. // rowData - rendered row's object. cellsRenderer: function (row, column, value, rowData) { var laptops = rowData; //alert (laptops.CompanyName); var container = "<div>"; //alert(laptops.length); for (var i = 0; i < 4; i++) { //var laptop = laptops[i]; var item = "<div style='float: left; width: 210px; overflow: hidden; white-space: nowrap; height: 265px;'>"; var image = "<div style='margin: 5px; margin-bottom: 3px;'>"; var imgurl = '../../images/l-18.gif'; var img = '<img width=160 height=120 style="display: block;" src="' + imgurl + '"/>'; image += img; image += "</div>"; var info = "<div style='margin: 5px; margin-left: 10px; margin-bottom: 3px;'>"; info += "<div><i>" + "res[i+1].ContactName" + "</i></div>"; info += "<div>Price: $" + laptops.ContactName + "</div>"; info += "<div>RAM: " + "laptop.ram" + "</div>"; info += "<div>HDD: " + "laptop.hdd" + "</div>"; info += "<div>CPU: " + "j" + "</div>"; info += "<div>Display: " + laptops.CompanyName + "</div>"; info += "</div>"; var buy = "<button class='buy' style='margin: 5px; width: 80px; left: -40px; position: relative; margin-left: 50%; margin-bottom: 3px;'>Buy</button>"; item += image; item += info; item += buy; item += "</div>"; container += item; } container += "</div>"; return container; } } ] }); }); </script> </head> <body class='default'> <div id="dataTable"></div> </body> </html>
<?php
#Include the connect.php file
include(‘connect.php’);
#Connect to the database
//connection String
$connect = mysql_connect($hostname, $username, $password)
or die(‘Could not connect: ‘ . mysql_error());
//select database
mysql_select_db($database, $connect);
//Select The database
$bool = mysql_select_db($database, $connect);
if ($bool === False){
print “can’t find $database”;
}
// get data and store in a json array
$query = “SELECT * FROM Customers”;
$from = 0;
$to = 30;
$query .= ” LIMIT “.$from.”,”.$to;$result = mysql_query($query) or die(“SQL Error 1: ” . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$customers[] = array(
‘CompanyName’ => $row[‘CompanyName’],
‘ContactName’ => $row[‘ContactName’],
‘ContactTitle’ => $row[‘ContactTitle’],
‘Address’ => $row[‘Address’],
‘City’ => $row[‘City’]
);
}echo json_encode($customers);
?>October 1, 2014 at 7:21 am in reply to: Binding jqxDataTable to Remote data Binding jqxDataTable to Remote data #60413Now I can put the data into the table but I get 4 equal containers(columns) in one row. How can I make it 4 different ?
<script type=”text/javascript”>
$(document).ready(function () {
var source =
{
datatype: “json”,
datafields: [
{ name: ‘CompanyName’, type: ‘string’},
{ name: ‘ContactName’, type: ‘string’},
{ name: ‘ContactTitle’, type: ‘string’},
{ name: ‘Address’, type: ‘string’},
{ name: ‘City’, type: ‘string’}
],
url: ‘data.php’,
cache: false
};
var dataAdapter = new $.jqx.dataAdapter(source);
var itemsInCart = 0;$(“#dataTable”).jqxDataTable(
{
width: 860,
source: dataAdapter,
sortable: true,
pageable: true,
pageSize: 3,
theme: ‘arctic’,
pagerButtonsCount: 5,
enableHover: false,
selectionMode: ‘none’,
rendered: function () {
$(“.buy”).jqxButton({ theme: ‘arctic’ });
$(“.buy”).click(function () {
itemsInCart++;
$(“.cart-top p”).html(itemsInCart + ” products”);
});
},
columns: [
{
text: ‘Products’, align: ‘left’, dataField: ‘model’,
// row – row’s index.
// column – column’s data field.
// value – cell’s value.
// rowData – rendered row’s object.
cellsRenderer: function (row, column, value, rowData) {
var laptops = rowData;
//alert (laptops.CompanyName);
var container = “<div>”;
//alert(laptops.length);
for (var i = 0; i < 4; i++) {
//var laptop = laptops[i];
var item = “<div style=’float: left; width: 210px; overflow: hidden; white-space: nowrap; height: 265px;’>”;
var image = “<div style=’margin: 5px; margin-bottom: 3px;’>”;
var imgurl = ‘../../images/l-18.gif’;
var img = ‘‘;
image += img;
image += “</div>”;var info = “<div style=’margin: 5px; margin-left: 10px; margin-bottom: 3px;’>”;
info += “<div><i>” + “res[i+1].ContactName” + “</i></div>”;
info += “<div>Price: $” + laptops.ContactName + “</div>”;
info += “<div>RAM: ” + “laptop.ram” + “</div>”;
info += “<div>HDD: ” + “laptop.hdd” + “</div>”;
info += “<div>CPU: ” + “j” + “</div>”;
info += “<div>Display: ” + laptops.CompanyName + “</div>”;
info += “</div>”;var buy = “<button class=’buy’ style=’margin: 5px; width: 80px; left: -40px; position: relative; margin-left: 50%; margin-bottom: 3px;’>Buy</button>”;
item += image;
item += info;
item += buy;
item += “</div>”;
container += item;
}
container += “</div>”;
return container;
}
}]
});
});</script>
September 29, 2014 at 2:38 pm in reply to: Binding jqxDataTable to Remote data Binding jqxDataTable to Remote data #60262How can I put data into the table instead of “laptopdata” ?
<!DOCTYPE html>
<html lang=”en”>
<head>
<link rel=”stylesheet” href=”../../jqwidgets/styles/jqx.base.css” media=”screen” />
<link rel=”stylesheet” href=”../../jqwidgets/styles/jqx.arctic.css” media=”screen” />
<link rel=”stylesheet” href=”../../styles/jqx.apireference.css” media=”screen” />
<link rel=”stylesheet” href=”../../styles/site.css” media=”screen” /><script type=”text/javascript” src=”../../scripts/format.js”></script>
<script type=”text/javascript” src=”../../scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”../../scripts/demos.js”></script>
<script type=”text/javascript” src=”../../scripts/demofunctions.js”></script>
<script type=”text/javascript” src=”../../jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”../../jqwidgets/jqxtabs.js”></script>
<script type=”text/javascript” src=”../../jqwidgets/jqxdata.js”></script>
<script type=”text/javascript” src=”../../jqwidgets/jqxdatatable.js”></script>
<script type=”text/javascript” src=”../../jqwidgets/jqxbuttons.js”></script>
<script type=”text/javascript” src=”../../jqwidgets/jqxscrollbar.js”></script>
<script type=”text/javascript” src=”../../jqwidgets/jqxlistbox.js”></script>
<script type=”text/javascript” src=”../../jqwidgets/jqxdropdownlist.js”></script>
<script type=”text/javascript” src=”../../jqwidgets/jqxmenu.js”></script>
<script type=”text/javascript” src=”../../jqwidgets/jqxresponse.js”></script><script type=”text/javascript”>
$(document).ready(function () {
//initDemo();var source =
{
datatype: “json”,
datafields: [
{ name: ‘CompanyName’, type: ‘string’},
{ name: ‘ContactName’, type: ‘string’},
{ name: ‘ContactTitle’, type: ‘string’},
{ name: ‘Address’, type: ‘string’},
{ name: ‘City’, type: ‘string’}
],
url: ‘data.php’,
cache: false
};var dataAdapter = new $.jqx.dataAdapter(source);
var itemsInCart = 0;
$(“#dataTable”).jqxDataTable(
{
width: 860,
source: dataAdapter,
sortable: true,
pageable: true,
pageSize: 3,
theme: ‘arctic’,
pagerButtonsCount: 5,
enableHover: false,
selectionMode: ‘none’,
rendered: function () {
$(“.buy”).jqxButton({ theme: ‘arctic’ });
$(“.buy”).click(function () {
itemsInCart++;
$(“.cart-top p”).html(itemsInCart + ” products”);
});
},
columns: [
{
text: ‘Products’, align: ‘left’, dataField: ‘model’,
// row – row’s index.
// column – column’s data field.
// value – cell’s value.
// rowData – rendered row’s object.
cellsRenderer: function (row, column, value, rowData) {
//var laptops = rowData.laptops;
var container = “<div>”;
//alert(laptops.length);
for (var i = 0; i < 4; i++) {
//var laptop = laptops[i];
var item = “<div style=’float: left; width: 210px; overflow: hidden; white-space: nowrap; height: 265px;’>”;
var image = “<div style=’margin: 5px; margin-bottom: 3px;’>”;
var imgurl = ‘../../images/l-18.gif’;
var img = ‘‘;
image += img;
image += “</div>”;var info = “<div style=’margin: 5px; margin-left: 10px; margin-bottom: 3px;’>”;
info += “<div><i>” + “res[i+1].ContactName” + “</i></div>”;
info += “<div>Price: $” + “laptop.price” + “</div>”;
info += “<div>RAM: ” + “laptop.ram” + “</div>”;
info += “<div>HDD: ” + “laptop.hdd” + “</div>”;
info += “<div>CPU: ” + “laptop.cpu” + “</div>”;
info += “<div>Display: ” + “laptop.display” + “</div>”;
info += “</div>”;var buy = “<button class=’buy’ style=’margin: 5px; width: 80px; left: -40px; position: relative; margin-left: 50%; margin-bottom: 3px;’>Buy</button>”;
item += image;
item += info;
item += buy;
item += “</div>”;
container += item;
}
container += “</div>”;
return container;
}
}]
});
});</script>
</head>
<body class=’default’><div id=”dataTable”></div>
</body></html>
September 29, 2014 at 10:31 am in reply to: Binding jqxDataTable to Remote data Binding jqxDataTable to Remote data #60240Thank You for quick answer.
-
AuthorPosts