Cách 1: Lấy thông qua lệnh get jquery
<script>
var id_dh= urlGetValuePara("idDH"); // get giá trị trên url
var url_go="/adminxml/Query_Do.aspx?name=BanHang_iif/tbBanHang_get_by_ID&out=json&idHD="+id_dh;
//alert(id_dh); //test
// alert(url_go); //test
$.get(url_go, function(data, status){
//== set
//alert( JSON.stringify(data )); //test
if(data.Q1.length>0)
{
// alert(data.Q1[0].TongCongTien);
$("#TongCongTien").val(data.Q1[0].TongCongTien );
}
//$.each(data.Q1, function (index, itemData) {
//alert( itemData.TenCot);
//}); //each
}); //get
</script>
Cách 2: Lấy thông qua gán Query vào Form
- Vào tạo 1 Query có tên BanHang trong file QLBH.xml
<Query>
<ID>Q1</ID>
<Src>12</Src>
<Type>Sql</Type>
<Cmd>Select * From tbHangHoa</Cmd>
</Query>
<Query>
<ID>Q2</ID>
<Src>12</Src>
<Type>Sql</Type>
<Cmd>Select * From tbbanHang</Cmd>
</Query>
- Vào cấu hình Form gán tên Query vào QLBH/BanHang
- Sau đó thêm lệnh phần body hay file html nếu đã include vào body
<iif-F>
<Source><type:query/>#</>0</Source>
<ItemF>
+ <%i=TenHangHoa=i%><br>
</ItemF>
</iif-F>
<iif-F>
<Source><type:query/>#</>1</Source>
<ItemF>
+ <%i=TenKhachHang=i%><br>
</ItemF>
</iif-F>
0 là table thứ 1 ở Query đã tạo
1 là table thứ 2 ở Query đã tạo
Khi dùng trong HTML của From bắt buộc phải có vị trí query
<Source><type:query/>#</>0</Source>
*** Lấy không cần gán query vào cấu hình form
<iif-F>
<Source><type:query/>NhanVien</>0</Source>
<ItemF>
+ <%i=HoTen=i%><br>
</ItemF>
</iif-F>
-- Tham khảo định dạng hiện thị số / ngày
Cách 3: Lấy thông qua angular
Tạo 1 Query
<div ng-app="myApp" ng-controller="myCtrl">
<ul>
<li ng-repeat="x in Data_DonHang">
Số: {{x.So}}
</li>
</ul>
</div>
<script type="text/javascript">
var app = angular.module("myApp", []);
app.controller('myCtrl', function($scope, $http,$timeout){
$scope.loadDonHang = function () {
$(".alert_load_data").html("Load đơn hàng...");
$http({
method : "GET",
url : "Query_Do.aspx?name=BanHang_iif/DonHang&out=json"
}).then(
function mySuccess(response)
{
// alert( response.data);
$scope.Data_DonHang = response.data.Q1;
//Nếu Query nhiều table thì thêm $scope.Data_X = response.data.Q2;
$(".alert_load_data").hide();
}, function myError(response)
{
alert(response.statusText);
}
); //end then
$(".alert_load_data").html("");
} // end $scope.loadDonHang
$scope.loadDonHang();
//End CODE
});//end app.controller
</script>
Click tham khảo thêm