平台开发中的表格

  表格在平台开发过程中很重要能够方便的查询使用,bootstrap开发过程中的

用的比较多的是bootstrap-table连接http://bootstrap-table.wenzhixin.net.cn/zh-cn/getting-started/

还有datatables连接http://datatables.club/example/#data_sources,目前用的是第一种,使用中需要注意

的是,第二次请求的可用性以及table的高度合理不要拉两次滚动条实现下拉。

  使用样例代码

html

<div class="widget-box">
<table id="table"></table>
</div>

js

var $table = $('#table');
var first = 0;
$(document).ready(function() {
document.getElementById("alModelMenu").className = "submenu open";
document.getElementById("userModel").className = "active";


$("#queryDataBtn").click(function() {
var pins = $.trim($('#pins').val());

if (pins.replace(/[,;: ;:]/ig,"") == "") {
$('#pins').focus();
alert("请输入有效 pin 列表!");
return ;
}
pins = pins.replace(/[,;: ;:]/ig,",");
$('#pins').val(pins);


var url = "getUserPicture.do?pins="+pins;
if(first==0){
first=1;
var clientHight = document.body.clientHeight*0.38;
$table.bootstrapTable({
url: url,
height: clientHight,
columns: [ {
field: 'pin',
title: '用户'
}, {
field: 'shopOrder',
title: '购买店铺'
}, {
field: 'shopView',
title: '查看店铺'
}, {
field: 'pinCate3Prefer',
title: '三级品类偏好'
}, {
field: 'pinCate2Prefer',
title: '二级品类偏好'
}, {
field: 'pinCatePrefer',
title: '二三级偏好混排'
} , {
field: 'cmPin',
title: '移动、pc沉睡用户'
} , {
field: 'lepin',
title: '用户等级'
}, {
field: 'pinPriBra',
title: '偏好价格段'
}, {
field: 'PinCate3Brand',
title: '三级品牌偏好'
}, {
field: 'realTimePinCate3Prefer',
title: '实时三级品类偏好'
}, {
field: 'realTimePinCate2Prefer',
title: '实时二级品类偏好'
}, {
field: 'pinCate3PreferShort',
title: '短期偏好'
}, {
field: 'disoffLineVTagPrefer',
title: '内容偏好'
} , {
field: 'pinCat3',
title: '三级品类购买周期'
} , {
field: 'pinCate1Prefer',
title: '一级品类偏好'
} , {
field: 'pinCate1PreferLong',
title: '长期一级价格品类偏好'
} , {
field: 'pinCate3PreferVirtual',
title: '虚拟品类三级品类偏好'
} , {
field: 'pinPreferenceShop',
title: '实时店铺'
} ]
});
}else{
$table.bootstrapTable('refresh',{url: url});
}
});


$("#idPin").click(function(){
if($("#idPin").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pin');
}else{
$table.bootstrapTable('hideColumn', 'pin');
}
});

$("#idShopOrder").click(function(){
if($("#idShopOrder").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'shopOrder');
}else{
$table.bootstrapTable('hideColumn', 'shopOrder');
}
});

$("#idShopView").click(function(){
if($("#idShopView").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'shopView');
}else{
$table.bootstrapTable('hideColumn', 'shopView');
}
});

$("#idPinPreferenceShop").click(function(){
if($("#idPinPreferenceShop").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pinPreferenceShop');
}else{
$table.bootstrapTable('hideColumn', 'pinPreferenceShop');
}
});

$("#idPinCate1Prefer").click(function(){
if($("#idPinCate1Prefer").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pinCate1Prefer');
}else{
$table.bootstrapTable('hideColumn', 'pinCate1Prefer');
}
});

$("#idPinCate2Prefer").click(function(){
if($("#idPinCate2Prefer").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pinCate2Prefer');
}else{
$table.bootstrapTable('hideColumn', 'pinCate2Prefer');
}
});

$("#idPinCate3Prefer").click(function(){
if($("#idPinCate3Prefer").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pinCate3Prefer');
}else{
$table.bootstrapTable('hideColumn', 'pinCate3Prefer');
}
});

$("#idPinCatePrefer").click(function(){
if($("#idPinCatePrefer").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pinCatePrefer');
}else{
$table.bootstrapTable('hideColumn', 'pinCatePrefer');
}
});

$("#idDisoffLineVTagPrefer").click(function(){
if($("#idDisoffLineVTagPrefer").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'disoffLineVTagPrefer');
}else{
$table.bootstrapTable('hideColumn', 'disoffLineVTagPrefer');
}
});

$("#idPinCate1PreferLong").click(function(){
if($("#idPinCate1PreferLong").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pinCate1PreferLong');
}else{
$table.bootstrapTable('hideColumn', 'pinCate1PreferLong');
}
});

$("#idCmPin").click(function(){
if($("#idCmPin").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'cmPin');
}else{
$table.bootstrapTable('hideColumn', 'cmPin');
}
});

$("#idLepin").click(function(){
if($("#idLepin").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'lepin');
}else{
$table.bootstrapTable('hideColumn', 'lepin');
}
});

$("#idPinPriBra").click(function(){
if($("#idPinPriBra").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pinPriBra');
}else{
$table.bootstrapTable('hideColumn', 'pinPriBra');
}
});

$("#idPinCate3Brand").click(function(){
if($("#idPinCate3Brand").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'PinCate3Brand');
}else{
$table.bootstrapTable('hideColumn', 'PinCate3Brand');
}
});

$("#idRealTimePinCate2Prefer").click(function(){
if($("#idRealTimePinCate2Prefer").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'realTimePinCate2Prefer');
}else{
$table.bootstrapTable('hideColumn', 'realTimePinCate2Prefer');
}
});

$("#idRealTimePinCate3Prefer").click(function(){
if($("#idRealTimePinCate3Prefer").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'realTimePinCate3Prefer');
}else{
$table.bootstrapTable('hideColumn', 'realTimePinCate3Prefer');
}
});

$("#idPinCate3PreferShort").click(function(){
if($("#idPinCate3PreferShort").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pinCate3PreferShort');
}else{
$table.bootstrapTable('hideColumn', 'pinCate3PreferShort');
}
});

$("#idPinCat3").click(function(){
if($("#idPinCat3").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pinCat3');
}else{
$table.bootstrapTable('hideColumn', 'pinCat3');
}
});

$("#idPinCate3PreferVirtual").click(function(){
if($("#idPinCate3PreferVirtual").attr("checked")=='checked'){
$table.bootstrapTable('showColumn', 'pinCate3PreferVirtual');
}else{
$table.bootstrapTable('hideColumn', 'pinCate3PreferVirtual');
}
});

//复选框的值.
$("#all").click(function() {
if ($(this).attr("checked") == 'checked') { // 全选
$("input[name='clusters']").each(function() {
$(this).attr("checked", "checked");
$table.bootstrapTable('showColumn', 'pin');
});
} else { // 取消全选
$("input[name='clusters']").each(function() {
$(this).removeAttr("checked");
$table.bootstrapTable('hideColumn', 'pin');
});
}
});

});

转载于:https://www.cnblogs.com/freedommovie/p/6203541.html

Delphi是一种用于开发Windows平台应用程序的编程语言和集成开发环境。在Delphi,可以使用内置的控件和组件来创建和操作Excel表格。 要在Delphi开发Excel表格控件,首先要确保已经安装了相应的Excel组件库,例如Microsoft Office组件库或第三方的Excel控件库。 一旦安装了Excel组件库,就可以在Delphi的工具箱找到Excel控件。通过将Excel控件拖放到窗体上,就可以在应用程序使用Excel表格。 接下来,需要在代码实现与Excel表格的交互。通过使用Excel组件库提供的方法和属性,可以创建、读取、修改和保存Excel表格。例如,可以使用类似以下的代码来创建一个Excel表格并输入数据: ```delphi var ExcelApp: Variant; ExcelWorkbook: Variant; ExcelWorksheet: Variant; begin ExcelApp := CreateOleObject('Excel.Application'); ExcelApp.Visible := True; ExcelWorkbook := ExcelApp.Workbooks.Add; ExcelWorksheet := ExcelWorkbook.Worksheets[1]; ExcelWorksheet.Cells[1, 1].Value := '姓名'; ExcelWorksheet.Cells[1, 2].Value := '年龄'; ExcelWorksheet.Cells[2, 1].Value := '张三'; ExcelWorksheet.Cells[2, 2].Value := 25; ExcelWorksheet.Cells[3, 1].Value := '李四'; ExcelWorksheet.Cells[3, 2].Value := 30; ExcelWorkbook.SaveAs('C:\路径\文件名.xlsx'); ExcelWorkbook.Close; ExcelApp.Quit; end; ``` 通过上述代码,可以创建一个包含姓名和年龄数据的Excel表格,并将其保存在指定的路径。然后,可以在Delphi应用程序打开和读取该Excel表格,或者进行其他操作,例如修改和删除数据等。 以上是使用Delphi开发Excel表格控件的基本步骤和示例代码。通过研究Excel组件库提供的方法和属性,可以根据具体需求进一步扩展和优化应用程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值