用EXT的CHECKBOX表示BOOL型字段

SUI模板Checkbox提交默认值
探讨了在SUI模板中使用带有默认值的复选框时如何确保即使未选中也能正常提交的问题。文中提到一种方法是在更新ACTION中预先设定BOOL字段的默认值为'0',以解决未选中时参数缺失的情况。
在SUI模板中添加VALUE="1"
 
<input type="checkbox" sui="checkbox" name="page[hidden]" value="1" field_label="禁用" />

当用户未选中该复选框时,不会提交任何参数到后台,因此此时要在更新ACTION中为BOOL字段赋值

def update
params[:page][:hidden] ||= '0'
render :json => @page.to_ext_json(:success => @page.update_attributes(params[:page]))
end
根据代码,修改TableWidget 设置拖拽功能// WARNING! All changes made in this file will be lost! package uigen import ( "github.com/therecipe/qt/core" "github.com/therecipe/qt/widgets" ) type UIMomoMainWindow struct { Centralwidget *widgets.QWidget TableWidget *widgets.QTableWidget CheckBox *widgets.QCheckBox CheckBox2 *widgets.QCheckBox CheckBox3 *widgets.QCheckBox ColumnView *widgets.QColumnView PushButton *widgets.QPushButton PushButton2 *widgets.QPushButton PlainTextEdit *widgets.QPlainTextEdit Menubar *widgets.QMenuBar Statusbar *widgets.QStatusBar } func (this *UIMomoMainWindow) SetupUI(MainWindow *widgets.QMainWindow) { MainWindow.SetObjectName("MainWindow") MainWindow.SetGeometry(core.NewQRect4(0, 0, 1087, 732)) this.Centralwidget = widgets.NewQWidget(MainWindow, core.Qt__Widget) this.Centralwidget.SetObjectName("Centralwidget") this.TableWidget = widgets.NewQTableWidget(this.Centralwidget) this.TableWidget.SetObjectName("TableWidget") this.TableWidget.SetGeometry(core.NewQRect4(0, 0, 1091, 511)) this.TableWidget.SetColumnCount(9) this.TableWidget.SetRowCount(0) // 预创建所有表头项,确保它们存在 for i := 0; i < 9; i++ { tableItem := widgets.NewQTableWidgetItem(0) this.TableWidget.SetHorizontalHeaderItem(i, tableItem) } this.CheckBox = widgets.NewQCheckBox(this.Centralwidget) this.CheckBox.SetObjectName("CheckBox") this.CheckBox.SetGeometry(core.NewQRect4(20, 540, 61, 19)) this.CheckBox2 = widgets.NewQCheckBox(this.Centralwidget) this.CheckBox2.SetObjectName("CheckBox2") this.CheckBox2.SetGeometry(core.NewQRect4(110, 540, 61, 19)) this.CheckBox3 = widgets.NewQCheckBox(this.Centralwidget) this.CheckBox3.SetObjectName("CheckBox3") this.CheckBox3.SetGeometry(core.NewQRect4(190, 540, 91, 21)) this.ColumnView = widgets.NewQColumnView(this.Centralwidget) this.ColumnView.SetObjectName("ColumnView") this.ColumnView.SetGeometry(core.NewQRect4(270, 520, 811, 161)) this.PushButton = widgets.NewQPushButton(this.Centralwidget) this.PushButton.SetObjectName("PushButton") this.PushButton.SetGeometry(core.NewQRect4(20, 580, 231, 28)) this.PushButton2 = widgets.NewQPushButton(this.Centralwidget) this.PushButton2.SetObjectName("PushButton2") this.PushButton2.SetGeometry(core.NewQRect4(20, 630, 231, 28)) this.PlainTextEdit = widgets.NewQPlainTextEdit(this.Centralwidget) this.PlainTextEdit.SetObjectName("PlainTextEdit") this.PlainTextEdit.SetGeometry(core.NewQRect4(270, 520, 811, 161)) this.PlainTextEdit.SetStyleSheet("background-color: rgb(0, 0, 0);\ncolor: rgb(45, 111, 26);") MainWindow.SetCentralWidget(this.Centralwidget) this.Menubar = widgets.NewQMenuBar(MainWindow) this.Menubar.SetObjectName("Menubar") this.Menubar.SetGeometry(core.NewQRect4(0, 0, 1087, 26)) MainWindow.SetMenuBar(this.Menubar) this.Statusbar = widgets.NewQStatusBar(MainWindow) this.Statusbar.SetObjectName("Statusbar") MainWindow.SetStatusBar(this.Statusbar) this.RetranslateUi(MainWindow) } func (this *UIMomoMainWindow) RetranslateUi(MainWindow *widgets.QMainWindow) { _translate := core.QCoreApplication_Translate MainWindow.SetWindowTitle(_translate("MainWindow", "MainWindow", "", -1)) this.TableWidget.SetColumnCount(9) this.TableWidget.SetRowCount(0) this.TableWidget.HorizontalHeaderItem(0).SetText(_translate("MainWindow", "id", "", -1)) this.TableWidget.HorizontalHeaderItem(1).SetText(_translate("MainWindow", "moid", "", -1)) this.TableWidget.HorizontalHeaderItem(2).SetText(_translate("MainWindow", "用户名", "", -1)) this.TableWidget.HorizontalHeaderItem(3).SetText(_translate("MainWindow", "死活", "", -1)) this.TableWidget.HorizontalHeaderItem(4).SetText(_translate("MainWindow", "环境", "", -1)) this.TableWidget.HorizontalHeaderItem(5).SetText(_translate("MainWindow", "男女", "", -1)) this.TableWidget.HorizontalHeaderItem(6).SetText(_translate("MainWindow", "名字", "", -1)) this.TableWidget.HorizontalHeaderItem(7).SetText(_translate("MainWindow", "是否实名", "", -1)) this.TableWidget.HorizontalHeaderItem(8).SetText(_translate("MainWindow", "账号等级", "", -1)) this.CheckBox.SetText(_translate("MainWindow", "死号", "", -1)) this.CheckBox2.SetText(_translate("MainWindow", "实名", "", -1)) this.CheckBox3.SetText(_translate("MainWindow", "掉实名", "", -1)) this.PushButton.SetText(_translate("MainWindow", "开始任务", "", -1)) this.PushButton2.SetText(_translate("MainWindow", "导出结果", "", -1)) }
最新发布
08-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值