EasyUI Forum
September 14, 2025, 04:00:33 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
  Home Help Search Login Register  
  Show Posts
Pages: [1]
1  General Category / EasyUI for jQuery / Re: Merge cell in Datagrid Footer on: October 12, 2015, 10:35:43 PM
Its good. Thanks Jarry.
2  General Category / EasyUI for jQuery / Merge cell in Datagrid Footer on: October 11, 2015, 11:19:50 PM
This is a repost from topic http://www.jeasyui.com/forum/index.php?topic=3428.0

Is the feature has already on Version 1.4.3 ?

Thanks
3  General Category / EasyUI for jQuery / Re: Populating data from database to Datagrid with Checkbox on: September 26, 2015, 10:04:25 AM
Thanks for reply anda that the solution

i have change the sql
Code:
$sql = "SELECT 
main_data.itemid AS itemid,
                offer_data.itemid AS itemid2,
main_data.listprice AS listprice,
offer_data.unitcost AS unitcost,
offer_data.attr AS attr,
offer_data.statusId AS statusId
FROM main_data
LEFT JOIN offer_data ON offer_data.itemid = main_data.itemid";

And the change the JS
Code:
onLoadSuccess: function(data) {
$('#dg').datagrid('getPanel').find('div.datagrid-header input[type=checkbox]').attr('disabled','disabled');
for (var i=0; i<data.rows.length; i++) {
if(data.rows[i]['itemid] === data.rows[i]['itemid2']) {
$(this).datagrid('checkRow', i);
}
}
},
4  General Category / EasyUI for jQuery / Re: Populating data from database to Datagrid with Checkbox on: September 25, 2015, 04:55:04 AM
My apologize if my explanation on the top is not clear. so, his is what i mean.
I have datatabase name "test" and table "main_data" and "offer_data", with detail is

Data on table "main_data"
itemidlistprice
EST-1112
EST-2100
EST-398
EST-456
EST-588
EST-6121
EST-744
EST-876
EST-956

Data on table "offer_data"
itemidunitcostattrstatusId
EST-112Largetrue
EST-613Spotted Adult Femaletrue
EST-723Green Adulttrue
EST-923Adult Femalefalse

When i am on edit page, i'll show all data from table main_data to datagrid with data from table offer_data
where if main_data.itemid=offer_data.itemid that row automatic checked on load
This is my script

edit.php
Code:
<table id="dg" class="easyui-datagrid" style="width:600px"
url="data/main_data.php"
title="Edit Data" iconCls="icon-save" fitColumns="true"
idField="itemid">
<thead>
<tr>
<th field="ck" width="80" checkbox="true">Item ID</th>
<th field="itemid" width="80">Item ID</th>
<th field="listprice" width="80" align="right">List Price</th>
<th field="unitcost" width="80" align="right" data-options="editor:'numberbox'">Unit Cost</th>
<th field="attr" width="150" data-options="editor:'textbox'">Attribute</th>
<th field="statusId", data-options="align: 'center',
editor:{
type:'combobox',
options:{
valueField:'statusId',
textField:'statusName',
panelHeight:'auto',
data: [{
statusId: '',
statusName: '- Choose -'
},{
statusId: 'true',
statusName: 'Active'
},{
statusId: 'false',
statusName: 'Non Active'
}]
}
}
" width="80"><b>Status</b></th>
</tr>
</thead>
</table>


main_data.php
Code:
require_once('config.php');

$sql = "SELECT
main_data.itemid AS itemid,
main_data.listprice AS listprice,
offer_data.unitcost AS unitcost,
offer_data.attr AS attr,
offer_data.statusId AS statusId
FROM main_data
LEFT JOIN offer_data ON offer_data.itemid = main_data.itemid";

$result = $conn->query($sql);

$data = array();
while($row = mysqli_fetch_assoc($result)){
$data[] = $row;
}
echo json_encode($data);

Please someone help me,
Thanks
5  General Category / EasyUI for jQuery / Populating data from database to Datagrid with Checkbox [Solved] on: September 22, 2015, 10:36:25 PM
Now I can save the data from Datagrid with Checkbox, Combobox and Textbox to database.
http://www.jeasyui.com/forum/index.php?topic=5248.0

My question is:
How can i populate data from database to Datagrid and automatic fill the Checkbox, Combobox and Textbox ?

Please Help Me,
Thanks.


This is My Script:

HTML
Code:
<table id="dg" class="easyui-datagrid" style="width:600px;height:250px"
url="data/datagrid_data.json"
title="Load Data" iconCls="icon-save" fitColumns="true"
idField="itemid">
<thead>
<tr>
<th field="ck" width="80" checkbox="true">Item ID</th>
<th field="itemid" width="80">Item ID</th>
<th field="productid" width="80">Product ID</th>
<th field="listprice" width="80" align="right">List Price</th>
<th field="unitcost" width="80" align="right" data-options="editor:'numberbox'">Unit Cost</th>
<th field="attr1" width="150" data-options="editor:'textbox'">Attribute</th>
<th field="statusName", data-options="align: 'center',
editor:{
type:'combobox',
options:{
valueField:'statusId',
textField:'statusName',
panelHeight:'auto',
data: [{
statusId: '',
statusName: '- Choose -'
},{
statusId: 'true',
statusName: 'Active'
},{
statusId: 'false',
statusName: 'Non Active'
}]
}
}

" width="80"><b>Status</b></th>
</tr>
</thead>
</table>

Javascript
Code:
function save() {		
var rows = [];
var dg = $('#dg');
$.map(dg.datagrid('getChecked'), function(row){
var index = dg.datagrid('getRowIndex', row);
var editors = dg.datagrid('getEditors', index);
if (editors.length){
rows.push({
itemid: row.itemid,
unitcost: $(editors[0].target).numberbox('getValue'),
attr1: $(editors[1].target).textbox('getValue'),
statusName: $(editors[2].target).combobox('getValue')
});
}
});
$.ajax({
url:'./data.php',
type: 'POST',
data: {data: JSON.stringify(rows)},
cache: false
});
}

PHP (getdata.php)
Code:
$conn = mysqli_connect($host, $user, $pass, $db);
mysqli_query($conn, "SELECT * FROM tbl_test");
6  General Category / EasyUI for jQuery / Re: Datagrid getChecked data to Array, Post to PHP and Parse on: September 22, 2015, 06:36:15 AM
Thank for reply stworthy. Its Works.

And this i give the code

Javascript
Code:
function save() {		
var rows = [];
var dg = $('#dg');
$.map(dg.datagrid('getChecked'), function(row){
var index = dg.datagrid('getRowIndex', row);
var editors = dg.datagrid('getEditors', index);
if (editors.length){
rows.push({
itemid: row.itemid,
unitcost: $(editors[0].target).numberbox('getValue'),
attr1: $(editors[1].target).textbox('getValue'),
statusName: $(editors[2].target).combobox('getValue')
});
}
});
$.ajax({
url:'./data.php',
type: 'POST',
data: {data: JSON.stringify(rows)},
cache: false
});
}

PHP (data.php)
Code:
$conn = mysqli_connect($host, $user, $pass, $db);
$data = json_decode($_POST['data'], true);
mysqli_query($conn, "DELETE * FROM tbl_test");
foreach($data as $dt) {
mysqli_query($conn, "INSERT INTO tbl_test (itemid, unitcost, attr1, statusName) VALUES ('$dt[itemid]', '$dt[unitcost]', '$dt[attr1]', '$dt[statusName]')");
}
?>


I think is the good way, if i wrong please correct.
7  General Category / EasyUI for jQuery / Datagrid getChecked data to Array, Post to PHP and Parse [Solved] on: September 19, 2015, 02:31:16 AM
Hello All,
I have a problem with datagrid (not edatagrid) inline row editing, i try to modification easyui datagrid tutorial
http://www.jeasyui.com/tutorial/datagrid/datagrid3.php

My question is:
1. how can i get all checked row to array including numberbox, textbox and combobox value ?
2. post them to PHP ?
3. Parse the array ini PHP, so i can insert them to Database.

Please Help Me,
Thanks.

HTML
Code:
<table id="dg" class="easyui-datagrid" style="width:600px;height:250px"
url="data/datagrid_data.json"
title="Load Data" iconCls="icon-save" fitColumns="true"
idField="itemid">
<thead>
<tr>
<th field="ck" width="80" checkbox="true">Item ID</th>
<th field="itemid" width="80">Item ID</th>
<th field="productid" width="80">Product ID</th>
<th field="listprice" width="80" align="right">List Price</th>
<th field="unitcost" width="80" align="right" data-options="editor:'numberbox'">Unit Cost</th>
<th field="attr1" width="150" data-options="editor:'textbox'">Attribute</th>
<th field="statusName", data-options="align: 'center',
editor:{
type:'combobox',
options:{
valueField:'statusId',
textField:'statusName',
panelHeight:'auto',
data: [{
statusId: '',
statusName: '- Choose -'
},{
statusId: 'true',
statusName: 'Active'
},{
statusId: 'false',
statusName: 'Non Active'
}]
}
}

" width="80"><b>Status</b></th>
</tr>
</thead>
</table>

Javascript
Code:
<script>
function save() {
var ids = [];
var rows = $('#dg').datagrid('getSelections');
for(var i=0; i<rows.length; i++){
ids.push(rows[i].itemid);
}
alert(ids.join('\n'));
}


$(document).ready(function () {
var lastIndex;
$('#dg').datagrid({
onLoadSuccess: function(data) {
$('#dg').datagrid('getPanel').find('div.datagrid-header input[type=checkbox]').attr('disabled','disabled');
},
onCheck: function(index,row){
if(lastIndex != index) {
$(this).datagrid('beginEdit', index);
}
},
onUncheck: function(index,row){
if(lastIndex != index) {
$(this).datagrid('endEdit', index);
}
},

});
});
</script>
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!