class Pqgrid extends React.Component
{
componentDidMount()
{
this.options = this.props.options
pq.grid( this.refs.grid, this.options )
}
componentDidUpdate(prevProps)
{
Object.assign( this.options, this.props.options )
}
render()
{
//return ( <div style={{ height: '90%', position: 'absolute', left: '0px', width: '90%', overflow: 'hidden'}} ref="grid" ></div> )
return <div ref="grid" ></div>
}
}
class App extends React.Component
{
constructor( props )
{
super( props )
this.handleChange = this.handleChange.bind( this );
this.pqVS =
{
rpp: 500,
init: function()
{
this.totalRecords = 0
this.requestPage = 1
this.data = []
}
}
this.pqVS.init();
this.columns1 =
[
{ title: "Order ID", width: 100, dataIndx: "ord_id" },
{ title: "Product Id", width: 190, dataIndx: "item_id" },
{ title: "Product Name", width: 250, dataIndx: "item_name" },
{ title: "Quantity", width: 100, dataIndx: "ord_qnt", align:"right" },
{ title: "Order Date", width: 100, dataIndx: "ord_date"},
{ title: "Order Week", width: 100, dataIndx: "ord_week"},
{ title: "Return Date", width: 100, dataIndx: "ret_date" },
{ title: "Return Week", width: 100, dataIndx: "ret_week" },
{ title: "Fact Date", width: 100, dataIndx: "fact_date" },
{ title: "Fact Week", width: 100, dataIndx: "fact_week" },
]
this.data1 =
{
dataType: "JSON",
location: "remote",
url: "phpf/remote.php",
postData: function()
{
return
{
pq_curpage: this.pqVS.requestPage,
pq_rpp: this.pqVS.rpp
}
},
getData: function( response )
{
var data = response.data,
totalRecords = response.totalRecords,
len = data.length,
curPage = response.curPage,
pq_data = this.pqVS.data,
init = ( curPage - 1 ) * this.pqVS.rpp;
if ( !this.pqVS.totalRecords )
{
for ( var i = len; i < totalRecords; i++ )
{
pq_data[ i + init ] = { pq_empty: true }
}
this.pqVS.totalRecords = totalRecords
}
for ( var i = 0; i < len; i++ )
{
pq_data[ i + init ] = data[ i ]
pq_data[ i + init ].pq_empty = false
}
return { data: pq_data }
},
error: function ( jqXHR, textStatus, errorThrown)
{
//alert(errorThrown);
}
}
this.state =
{
reactive: true,
width: '98%',
height: '96%',
showTitle: false,
locale: 'lt',
menuIcon: false,
collapsible: { on: false, toggle: false },
resizable: true,
reactive: true,
scrollModel: { autoFit: false },
flex:{one: true},
numberCell: { show: false },
showHeader: true,
columnBorders: true,
rowBorders: true,
selectionModel: { type: 'cell' },
stripeRows: true,
filterModel: { header: false },
beforeTableView: function( evt, ui )
{
var initV = ui.initV,
finalV = ui.finalV,
data = this.pqVS.data,
rpp = this.pqVS.rpp,
requestPage;
if ( initV != null )
{
if ( data[ initV ] && data[ initV ].pq_empty )
{
requestPage = Math.floor( initV / rpp ) + 1
}
else if ( data[ finalV ] && data[ finalV ].pq_empty )
{
requestPage = Math.floor( finalV / rpp ) + 1
}
if ( requestPage >= 1 )
{
if ( this.pqVS.requestPage != requestPage )
{
this.pqVS.requestPage = requestPage
this.refreshDataAndView()
}
}
}
}, // columnTemplate: { width: 100 },
colModel: this.columns1,
animModel: { on: true },
dataModel: { data: this.data1 }
}
}
handleChange( event )
{
this.setState( { locale: event.target.value } )
}
render()
{
return <div>
<div style={{ margin: 20 }}>
<label>Change locale:</label>
<select value={this.state.locale} onChange={this.handleChange}>
<option value="lt">Lthuania</option>
<option value="en">English</option>
</select>
</div>
<Pqgrid options={this.state} />
</div>
}
}
ReactDOM.render(
<App />,
document.getElementById( 'app' )
)
postData: function()
{
return
{
pq_curpage: this.pqVS.requestPage,
pq_rpp: this.pqVS.rpp
}
},
<!DOCTYPE html>
<html lang="lt">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.css" rel="stylesheet" />
<link href="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.structure.css" rel="stylesheet" />
<link href="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.theme.css" rel="stylesheet" />
<script src="https://unpkg.com/jquery@1.11.2/dist/jquery.js"></script>
<script src="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.js"></script>
<link href="dist/pqgrid.min.css" rel="stylesheet" />
<link href="dist/pqgrid.ui.min.css" rel="stylesheet" />
<link href="dist/themes/chocolate/pqgrid.css" rel="stylesheet" />
<script src="dist/pqgrid.min.js"></script>
<script src="dist/pq-localize-en.js"></script>
<script src="dist/pq-localize-lt.js"></script>
<script src="dist/react.development.js"></script>
<script src="dist/react-dom.development.js"></script>
<script src="dist/babel.js"></script>
</head>
<body>
<div id="app"></div> <!-- style = { { height:'98vh' } }></div-->
<script type = "text/babel" src="index.js"></script>
</body>
</html>
postData: function()
{
return
{
this.pq_curpage = pqVS.requestPage,
this.pq_rpp = pqVS.rpp
};
},
Vue.component( "pq-grid",
{
props: ["options"],
mounted: function()
{
pq.grid(this.$el, this.options);
},
template: '<div :options="options"></div>'
});
var app = new Vue(
{
el: "#app",
columns1:
[
{ title: "Order ID", width: 100, dataIndx: "ord_id" },
{ title: "Product Id", width: 190, dataIndx: "item_id" },
{ title: "Product Name", width: 250, dataIndx: "prekes_pvd" },
{ title: "Quantity", width: 100, dataIndx: "ord_qnt", align:"right" },
{ title: "Order Date", width: 100, dataIndx: "ord_date"},
{ title: "Order Week", width: 100, dataIndx: "ord_week"},
{ title: "Return Date", width: 100, dataIndx: "ret_date" },
{ title: "Return Week", width: 100, dataIndx: "ret_week" },
{ title: "Fact Date", width: 100, dataIndx: "fact_date" },
{ title: "Fact Week", width: 100, dataIndx: "fact_week" },
],
data1:
{
dataType: "JSON",
location: "remote",
url: "phpf/remote.php",
postData: function()
{
return
{
pq_curpage = pqVS.requestPage,
pq_rpp = pqVS.rpp
};
},
getData: function( response )
{
var data = response.data,
totalRecords = response.totalRecords,
len = data.length,
curPage = response.curPage,
pq_data = pqVS.data,
init = ( curPage - 1 ) * pqVS.rpp;
if ( !pqVS.totalRecords )
{
for ( var i = len; i < totalRecords; i++ )
{
pq_data[ i + init ] = { pq_empty: true }
}
pqVS.totalRecords = totalRecords
}
for ( var i = 0; i < len; i++ )
{
pq_data[ i + init ] = data[ i ]
pq_data[ i + init ].pq_empty = false
}
return { data: pq_data }
},
error: function ( jqXHR, textStatus, errorThrown)
{
//alert(errorThrown);
}
},
data: function()
{
var pqVS =
{
rpp: 500,
init: function()
{
this.totalRecords = 0
this.requestPage = 1
this.data = []
}
}
pqVS.init();
this.options =
{
showTitle: false,
reactive: true,
locale: "lt",
height: "flex",
numberCell: { show: false },
columnTemplate: { width: 100 },
colModel: this.$options.columns1,
animModel: { on: true },
dataModel: { data: this.$options.data1 }
};
return {};
}
});
dataModel: this.data1
var pqVS =
{
rpp: 500,
init: function()
{
this.totalRecords = 0
this.requestPage = 1
this.data = []
}
}
pqVS.init();
Vue.component( "pq-grid",
{
props: ["options"],
mounted: function()
{
pq.grid(this.$el, this.options);
},
template: '<div :options="options"></div>'
});
var app = new Vue(
{
el: "#app",
columns1:
[
{ title: "Order ID", width: 100, dataIndx: "ord_id" },
{ title: "Product Id", width: 190, dataIndx: "item_id" },
{ title: "Product Name", width: 250, dataIndx: "prekes_pvd" },
{ title: "Quantity", width: 100, dataIndx: "ord_qnt", align:"right" },
{ title: "Order Date", width: 100, dataIndx: "ord_date"},
{ title: "Order Week", width: 100, dataIndx: "ord_week"},
{ title: "Return Date", width: 100, dataIndx: "ret_date" },
{ title: "Return Week", width: 100, dataIndx: "ret_week" },
{ title: "Fact Date", width: 100, dataIndx: "fact_date" },
{ title: "Fact Week", width: 100, dataIndx: "fact_week" },
],
data1:
{
dataType: "JSON",
location: "remote",
url: "phpf/remote.php",
postData: function()
{
return
{
pq_curpage = pqVS.requestPage,
pq_rpp = pqVS.rpp
};
},
getData: function( response )
{
debugger
var data = response.data,
totalRecords = response.totalRecords,
len = data.length,
curPage = response.curPage,
pq_data = pqVS.data,
init = ( curPage - 1 ) * pqVS.rpp;
if ( !pqVS.totalRecords )
{
for ( var i = len; i < totalRecords; i++ )
{
pq_data[ i + init ] = { pq_empty: true }
}
pqVS.totalRecords = totalRecords
}
for ( var i = 0; i < len; i++ )
{
pq_data[ i + init ] = data[ i ]
pq_data[ i + init ].pq_empty = false
}
return { data: pq_data }
},
error: function ( jqXHR, textStatus, errorThrown)
{
//alert(errorThrown);
}
},
data: function()
{
this.options =
{
showTitle: false,
reactive: true,
locale: "lt",
height: "flex",
numberCell: { show: false },
columnTemplate: { width: 100 },
colModel: this.$options.columns1,
animModel: { on: true },
dataModel: this.data1 //{ data: this.$options.data1 }
};
return {};
}
});
dataModel: this.data1
dataModel: this.$options.data1
postData: function () {
return {
pq_curpage: pqVS.requestPage,
pq_rpp: pqVS.rpp
};
},
<!DOCTYPE html>
<html lang="lt">
<head>
<meta charset=utf-8 />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.css" rel="stylesheet" />
<link href="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.structure.css" rel="stylesheet" />
<link href="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.theme.css" rel="stylesheet" />
<script src="https://unpkg.com/jquery@1.11.2/dist/jquery.js"></script>
<script src="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.js"></script>
<link href="dist/pqgrid.min.css" rel="stylesheet" />
<link href="dist/pqgrid.ui.min.css" rel="stylesheet" />
<link href="dist/themes/chocolate/pqgrid.css" rel="stylesheet" />
<script src="dist/pqgrid.min.js"></script>
<script src="dist/pq-localize-en.js"></script>
<script src="dist/pq-localize-lt.js"></script>
<script src="dist/vue.js"></script>
</head>
<body>
<div id="app">
<div style="margin:20px;">
<label>Change locale:</label>
<select v-model="options.locale">
<option value="en">English</option>
<option value="lt">Lithuania</option>
</select>
</div>
<pq-grid :options="options"></pq-grid>
</div>
<script src="index2.js" ></script>
</body>
</html>
var pqVS =
{
rpp: 500,
init: function()
{
this.totalRecords = 0
this.requestPage = 1
this.data = []
}
}
pqVS.init();
Vue.component( "pq-grid",
{
props: ["options"],
mounted: function()
{
pq.grid(this.$el, this.options);
},
template: '<div :options="options"></div>'
});
var app = new Vue(
{
el: "#app",
columns1:
[
{ title: "Order ID", width: 100, dataIndx: "ord_id" },
{ title: "Product Id", width: 190, dataIndx: "item_id" },
{ title: "Product Name", width: 250, dataIndx: "prekes_pvd" },
{ title: "Quantity", width: 100, dataIndx: "ord_qnt", align:"right" },
{ title: "Order Date", width: 100, dataIndx: "ord_date"},
{ title: "Order Week", width: 100, dataIndx: "ord_week"},
{ title: "Return Date", width: 100, dataIndx: "ret_date" },
{ title: "Return Week", width: 100, dataIndx: "ret_week" },
{ title: "Fact Date", width: 100, dataIndx: "fact_date" },
{ title: "Fact Week", width: 100, dataIndx: "fact_week" },
],
data1:
{
dataType: "JSON",
location: "remote",
url: "phpf/remote.php",
postData: function()
{
return
{
pq_curpage = pqVS.requestPage,
pq_rpp = pqVS.rpp
};
},
getData: function( response )
{
var data = response.data,
totalRecords = response.totalRecords,
len = data.length,
curPage = response.curPage,
pq_data = pqVS.data,
init = ( curPage - 1 ) * pqVS.rpp;
if ( !pqVS.totalRecords )
{
for ( var i = len; i < totalRecords; i++ )
{
pq_data[ i + init ] = { pq_empty: true }
}
pqVS.totalRecords = totalRecords
}
for ( var i = 0; i < len; i++ )
{
pq_data[ i + init ] = data[ i ]
pq_data[ i + init ].pq_empty = false
}
return { data: pq_data }
},
error: function ( jqXHR, textStatus, errorThrown)
{
//alert(errorThrown);
}
},
data: function()
{
this.options =
{
showTitle: false,
reactive: true,
locale: "lt",
height: "flex",
numberCell: { show: false },
columnTemplate: { width: 100 },
colModel: this.$options.columns1,
animModel: { on: true },
dataModel: this.data1 //{ data: this.$options.data1 }
};
return {};
}
});
<?php require_once 'conf2.php'; $dbh = getDatabaseHandle(); $sql = "select orders.*, items.prekes_pvd from orders left join items on items.prekes_id = orders.item_id and items.prekes_tipo_id ='prod'"; $pq_curPage = $_GET["pq_curpage"]; $pq_rPP=$_GET["pq_rpp"]; $sqt = "Select count(*) from orders"; $stmt = $dbh->query($sqt); $total_Records = $stmt->fetchColumn(); $skip = ($pq_rPP * ($pq_curPage - 1)); if ($skip >= $total_Records) { $pq_curPage = ceil($total_Records / $pq_rPP); $skip = ($pq_rPP * ($pq_curPage - 1)); } $sql .= " limit " . $skip . ", " .$pq_rPP; $stmt = $dbh->query($sql); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $sb = "{\"totalRecords\":" . $total_Records . ",\"curPage\":" . $pq_curPage . ",\"data\":".json_encode($rows)."}"; echo $sb;?>
postData: function()
{
var pst = {}
pst[ "pq_curpage" ] = pqVS.requestPage
pst[ "pq_rpp" ] = pqVS.rpp
return pst;
},
dataModel: this.$options.data1
<?php require_once 'conf2.php'; $dbh = getDatabaseHandle(); $sql = "select orders.*, items.prekes_pvd from orders left join items on items.prekes_id = orders.item_id and items.prekes_tipo_id ='prod'"; $url = $_SERVER[ 'QUERY_STRING' ]; parse_str( $url, $rqs ); $pq_curPage = $rqs[ "pq_curpage" ]; $pq_rPP= $rqs[ "pq_rpp" ]; $sqt = "Select count(*) from orders"; $stmt = $dbh->query($sqt); $total_Records = $stmt->fetchColumn(); $skip = ($pq_rPP * ($pq_curPage - 1)); if ($skip >= $total_Records) { $pq_curPage = ceil($total_Records / $pq_rPP); $skip = ($pq_rPP * ($pq_curPage - 1)); } $sql .= " limit " . $skip . ", " .$pq_rPP; $stmt = $dbh->query($sql); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $jrt = []; $jrt[ "totalRecords" ] = $total_Records; $jrt[ "curPage" ] = $pq_curPage; $jrt[ "data" ] = $rows; echo json_encode( $jrt );?>
<!DOCTYPE html>
<html lang="lt">
<head>
<meta charset=utf-8 />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.css" rel="stylesheet" />
<link href="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.structure.css" rel="stylesheet" />
<link href="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.theme.css" rel="stylesheet" />
<script src="https://unpkg.com/jquery@1.11.2/dist/jquery.js"></script>
<script src="https://unpkg.com/jquery-ui-pack@1.12.2/jquery-ui.js"></script>
<link href="dist/pqgrid.min.css" rel="stylesheet" />
<link href="dist/pqgrid.ui.min.css" rel="stylesheet" />
<link href="dist/themes/chocolate/pqgrid.css" rel="stylesheet" />
<script src="dist/pqgrid.min.js"></script>
<script src="dist/pq-localize-en.js"></script>
<script src="dist/pq-localize-lt.js"></script>
<script src="dist/react.development.js"></script>
<script src="dist/react-dom.development.js"></script>
<script src="dist/babel.js"></script>
</head>
<body>
<div id="app" style="height: 99vh;" ></div>
<script type = "text/babel" src="index.js"></script>
</body>
</html>
class Pqgrid extends React.Component
{
componentDidMount()
{
this.options = this.props.options
pq.grid( this.refs.grid, this.options )
}
componentDidUpdate(prevProps)
{
Object.assign( this.options, this.props.options )
}
render()
{
return <div style={{ height: '90vh'}} ref="grid" ></div>
}
}
class App extends React.Component
{
constructor( props )
{
super( props )
this.handleChange = this.handleChange.bind( this );
var pqVS =
{
rpp: 500,
init: function()
{
this.totalRecords = 0
this.requestPage = 1
this.data = []
}
}
pqVS.init();
this.columns1 =
[
{ title: "Order ID", width: 100, dataIndx: "ord_id" },
{ title: "Product Id", width: 190, dataIndx: "item_id" },
{ title: "Product Name", width: 250, dataIndx: "prekes_pvd" },
{ title: "Quantity", width: 100, dataIndx: "ord_qnt", align:"right" },
{ title: "Order Date", width: 100, dataIndx: "ord_date"},
{ title: "Order Week", width: 100, dataIndx: "ord_week"},
{ title: "Return Date", width: 100, dataIndx: "ret_date" },
{ title: "Return Week", width: 100, dataIndx: "ret_week" },
{ title: "Fact Date", width: 100, dataIndx: "fact_date" },
{ title: "Fact Week", width: 100, dataIndx: "fact_week" },
]
this.data1 =
{
dataType: "JSON",
location: "remote",
url: "phpf/remote.php",
postData: function()
{
var pst = {}
pst[ "pq_curpage" ] = pqVS.requestPage
pst[ "pq_rpp" ] = pqVS.rpp
return pst;
},
getData: function( response )
{
var data = response.data,
totalRecords = response.totalRecords,
len = data.length,
curPage = response.curPage,
pq_data = pqVS.data,
init = ( curPage - 1 ) * pqVS.rpp;
if ( !pqVS.totalRecords )
{
for ( var i = len; i < totalRecords; i++ )
{
pq_data[ i + init ] = { pq_empty: true }
}
pqVS.totalRecords = totalRecords
}
for ( var i = 0; i < len; i++ )
{
pq_data[ i + init ] = data[ i ]
pq_data[ i + init ].pq_empty = false
}
return { data: pq_data }
},
error: function ( jqXHR, textStatus, errorThrown)
{
//alert(errorThrown);
}
}
this.state =
{
reactive: true,
width: '98%',
height: '96%',
showTitle: false,
locale: 'lt',
menuIcon: false,
collapsible: { on: false, toggle: false },
resizable: true,
reactive: true,
scrollModel: { autoFit: false },
flex:{one: true},
numberCell: { show: false },
showHeader: true,
columnBorders: true,
rowBorders: true,
selectionModel: { type: 'cell' },
stripeRows: true,
filterModel: { header: false },
beforeTableView: function( evt, ui )
{
var initV = ui.initV,
finalV = ui.finalV,
data = pqVS.data,
rpp = pqVS.rpp,
requestPage;
if ( initV != null )
{
if ( data[ initV ] && data[ initV ].pq_empty )
{
requestPage = Math.floor( initV / rpp ) + 1
}
else if ( data[ finalV ] && data[ finalV ].pq_empty )
{
requestPage = Math.floor( finalV / rpp ) + 1
}
if ( requestPage >= 1 )
{
if ( pqVS.requestPage != requestPage )
{
pqVS.requestPage = requestPage
this.refreshDataAndView()
}
}
}
},
colModel: this.columns1,
animModel: { on: true },
dataModel: this.data1
}
}
handleChange( event )
{
this.setState( { locale: event.target.value } )
}
render()
{
return <div>
<div style={{ margin: 20 }}>
<label>Change locale:</label>
<select value={this.state.locale} onChange={this.handleChange}>
<option value="lt">Lthuania</option>
<option value="en">English</option>
</select>
</div>
<Pqgrid options={this.state} />
</div>
}
}
ReactDOM.render(
<App />,
document.getElementById( 'app' )
)