jQuery UI Widgets › Forums › Grid › jqxgrid sql getcellvalue
Tagged: angular grid, angular2 grid, bootstrap grid, javascript grid, jquery grid, jqwidgets grid, jqxgrid, typescript grid
This topic contains 1 reply, has 2 voices, and was last updated by Hristo 7 years, 11 months ago.
-
Authorjqxgrid sql getcellvalue Posts
-
Hi i have problem with getcellvalue in jqxgrid button. The button ‘View’ is a cellrenderer that is retrieving the getcellvalue property, but for some reason whitespaced values are not retrieving. For example check in the image link I posted below, notice the column Store and that first row has a value as Pizza Parlor. Now when I hover over to the action button ‘View’, it is only showing that the value as “Pizza”. Its missing the rest of the cell’s value. You can see the link below with the correct path it should show.
It should correctly show localhost/new1/openstore.php?store_name=Pizza Parlor
But what i have now is showing localhost/new1/openstore.php?store_name=Pizza
Image: https://postimg.org/image/ni280qlhb/
Here is my code:
data2.php:
<?php
session_start();
#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 The database
$bool = mysql_select_db($database, $connect);
if ($bool === False){
print “can’t find $database”;
}$query =”Select * from stores WHERE
addedbyuser
= ‘”.$_SESSION[“username”].”‘”;
// sort data.
if (isset($_GET[‘sortdatafield’]))
{
$sortfield = $_GET[‘sortdatafield’];
$sortorder = $_GET[‘sortorder’];if ($sortfield != NULL)
{
if ($sortorder == “desc”)
{
$query = “SELECT * FROM stores ORDER BY” . ” ” . $sortfield . ” DESC”;
}
else if ($sortorder == “asc”)
{
$query = “SELECT * FROM stores ORDER BY” . ” ” . $sortfield . ” ASC”;
}
}
}
if (isset($_GET[‘update’]))
{
// UPDATE COMMAND
$update_query = “UPDATEstores
SETstore_name
='”.$_GET[‘store_name’].”‘,
address
='”.$_GET[‘address’].”‘,
city
='”.$_GET[‘city’].”‘,
state
='”.$_GET[‘state’].”‘,
zip
='”.$_GET[‘zip’].”‘,
phone
='”.$_GET[‘phone’].”‘ WHEREid
='”.$_GET[‘id’].”‘”;
$result = mysql_query($update_query) or die(“SQL Error 1: ” . mysql_error());
echo $result;
}
else
{
$result = mysql_query($query) or die(“SQL Error 1: ” . mysql_error());
// get data and store in a json array
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$stores[] = array(
‘id’ => $row[‘id’],
‘store_name’ => $row[‘store_name’],
‘address’ => $row[‘address’],
‘city’ => $row[‘city’],
‘state’ => $row[‘state’],
‘zip’ => $row[‘zip’],
‘phone’ => $row[‘phone’],
//’addedbyuser’ => $row[‘addedbyuser’]
);
}echo json_encode($stores);
}
?>Index.php
<script type=”text/javascript”>
$(document).ready(function () {
// ??(??)var source =
{
datatype: “json”,
datafields: [
{ name: ‘id’},
{ name: ‘store_name’},
{ name: ‘address’},
{ name: ‘city’},
{ name: ‘state’},
{ name: ‘zip’},
{ name: ‘phone’},
{ name: ‘addedbyuser’}
],
url: ‘data2.php’,
id: ‘addedbyuser’,
root: ‘Rows’,
beforeprocessing: function (data) {
source.totalrecords = data[0].TotalRows;
},
updaterow: function (rowid, rowdata) {
// synchronize with the server – send update commandvar data = “update=true&store_name=” + rowdata.store_name + “&address=” + rowdata.address + “&city=” + rowdata.city;
data = data + “&state=” + rowdata.state + “&zip=” + rowdata.zip + “&phone=” + rowdata.phone;
data = data + “&id=” + rowdata.id;
$.ajax({
dataType: ‘json’,
url: ‘data2.php’,
data: data,
id: ‘addedbyuser’,
success: function (data, status, xhr) {
// update command is executed.
}
});
}
};var dataAdapter = new $.jqx.dataAdapter(source);
var renderer = function (row, column, value) {
if (value.indexOf(‘#’) != -1) {
value = value.substring(0, value.indexOf(‘#’));
}
var href = $(‘#jqxgrid’).jqxGrid(‘getcellvalue’, row, “store_name”);
var deletestore = $(‘#jqxgrid’).jqxGrid(‘getcellvalue’, row, “id”);
return “<button style=’margin:3px;’ class=’btn btn-sm btn-info’><span class=’glyphicon glyphicon-zoom-in’></span> View</button>” + value + ““+”<button style=’margin-left: 5px;’ class=’btn btn-sm btn-danger’><span class=’glyphicon glyphicon-remove-circle’></span> Delete</button>” + value + ““;
};var linkrenderer = function (row, column, value) {
if (value.indexOf(‘#’) != -1) {
value = value.substring(0, value.indexOf(‘#’));
}
var title = $(‘#jqxgrid’).jqxGrid(‘getcellvalue’, row, “actions”);
return ‘<button class=”btn btn-sm btn-danger” id=”second”><span class=”glyphicon glyphicon-remove-circle”></span> Delete</button>’ + title + ‘‘;
/*
if (row == 1){
var title = $(‘#jqxgrid2’).jqxGrid(‘getcellvalue’, row, “nhinchk”);
return “” + title + ““;
}
*/
}$(“#jqxgrid”).jqxGrid(
{
width: ‘100%’,
autoheight: true,
source: dataAdapter,
//keyboardnavigation: false,
filterable: true,
sortable: true,
editable: true,
editmode: ‘dblclick’,
showfilterrow: true,
altrows: true,
enablehover: true,
pageable: true,
showtoolbar: true,
rowsheight: 40,
showstatusbar: true,
pagesize: 15,
columnsresize: true,
columnsreorder: true,
columnsautoresize: true,
enablebrowserselection: true,
theme:’jqx-ar’,
selectionmode: ‘singlerow’,
columns: [
{ text: ‘??’, datafield: ‘id’, width: 100, hidden: true},
{ text: ‘Store’, datafield: ‘store_name’, width: 100, resizable:false},
{ text: ‘Actions’, datafield: ‘actions’, width: 155, editable: false, filterable: false, menu: false, sortable: false, resizable:false, cellsrenderer: renderer },
{ text: ‘Address’, datafield: ‘address’, width: 150, resizable:false },
{ text: ‘City’, datafield: ‘city’, width: 180, resizable:false },
{ text: ‘State’, datafield: ‘state’, width: 200, resizable:false },
{ text: ‘Zip Code’, datafield: ‘zip’, width: 200, resizable:false },
{ text: ‘Phone Number’, datafield: ‘phone’, width: 150, resizable:false}],
showtoolbar: true,
rendertoolbar: function (toolbar) {
var me = this;
var container = $(“<div style=’margin: 5px;’></div>”);
var button = $(“<button type=’button’ style=’color: black; background: white; ‘ class=’btn btn-success’ data-toggle=’modal’ data-target=’#myModal’><span class=’glyphicon glyphicon-plus’></span> Add New Store</button>”);
toolbar.append(container);
container.append(button);
button.jqxButton({ height: ‘100%’, width: 200 });}
});}); //end ready
</script>Hello dan123,
I would like to suggest you this topic.
Also, this one.
Hope this helps.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.