$('#freight_Declar').numberbox('setValue',$('#freight_Declar').val() == null||$('#freight_Declar').val() ==""?0:$('#freight_Declar').val(),null);触发change事件
时间: 2024-01-08 13:02:58 浏览: 78
在 EasyUI 的 `numberbox` 组件中,如果需要在设置值后触发 `change` 事件,可以使用 `triggerHandler` 方法来手动触发事件。以下是一个示例代码:
```javascript
// 获取 numberbox 元素
var numberbox = $('#freight_Declar');
// 设置值
numberbox.numberbox('setValue', ($('#freight_Declar').val() == null || $('#freight_Declar').val() == "") ? 0 : $('#freight_Declar').val());
// 触发 change 事件
numberbox.triggerHandler('change');
```
在上面的示例代码中,我们首先获取到 `numberbox` 元素,并使用 `numberbox.numberbox('setValue', value)` 方法来设置值,其中的 `value` 是根据你的条件设置的值。
然后,我们使用 `triggerHandler('change')` 方法来手动触发 `change` 事件。
请注意,使用 `triggerHandler` 方法只会触发事件的回调函数,而不会实际触发浏览器中的事件。如果需要同时触发浏览器中的事件,请使用 `trigger` 方法。
根据实际需求,你可以根据新值和旧值进行相应的逻辑处理。
相关问题
把以下sqlite的插入语句,转换成有效的mysql语句 String add_sql = "INSERT INTO detail(" "name," "width," "height," "quantity," "material," "thickness," "stiffiness," "density," "materialUnitPrice," "materialSize,pcs," "columnNum," "rowNum," "machineUnitPrice," "sampleCost," "shearPlate," "levelling," "freight," "others," "costUnitPrice," "quotePrice," "shearPlateAmount," "standbyPlate," "actualWeight," "sales," "estimateCost," "futureProfit," "createtime) " "VALUES('$v_name'," "'$v_width'," "'$v_height'," "'$v_quantity'," "'$v_material'," "'$v_thickness'," "'$v_stiffiness'," "'$v_density'," "'$v_materialUnitPrice'," "'$v_materialSize'," "'$v_pcs'," "'$v_columnNum'," "'$v_rowNum'," "'$v_machineUnitPrice'," "'$v_sampleCost'," "'$v_shearPlate'," "'$v_levelling'," "'$v_freight'," "'$v_others'," "'$v_costUnitPrice'," "'$v_quotePrice'," "'$v_shearPlateAmount'," "'$v_standbyPlate'," "'$v_actualWeight'," "'$v_sales'," "'$v_estimateCost'," "'$v_futureProfit'," "'$v_createtime')";
以下是将您提供的SQLite插入语句转换为有效的MySQL语句的方法:
```
String add_sql = "INSERT INTO detail("
"name,"
"width,"
"height,"
"quantity,"
"material,"
"thickness,"
"stiffiness,"
"density,"
"materialUnitPrice,"
"materialSize_pcs,"
"columnNum,"
"rowNum,"
"machineUnitPrice,"
"sampleCost,"
"shearPlate,"
"levelling,"
"freight,"
"others,"
"costUnitPrice,"
"quotePrice,"
"shearPlateAmount,"
"standbyPlate,"
"actualWeight,"
"sales,"
"estimateCost,"
"futureProfit,"
"createtime) "
"VALUES('$v_name',"
"'$v_width',"
"'$v_height',"
"'$v_quantity',"
"'$v_material',"
"'$v_thickness',"
"'$v_stiffiness',"
"'$v_density',"
"'$v_materialUnitPrice',"
"'$v_materialSize,$v_pcs',"
"'$v_columnNum',"
"'$v_rowNum',"
"'$v_machineUnitPrice',"
"'$v_sampleCost',"
"'$v_shearPlate',"
"'$v_levelling',"
"'$v_freight',"
"'$v_others',"
"'$v_costUnitPrice',"
"'$v_quotePrice',"
"'$v_shearPlateAmount',"
"'$v_standbyPlate',"
"'$v_actualWeight',"
"'$v_sales',"
"'$v_estimateCost',"
"'$v_futureProfit',"
"'$v_createtime')";
// 以下是将单引号转义处理
add_sql = add_sql.replaceAll("'", "\\'");
// 将 $v_materialSize,$v_pcs 拆分成两个变量 $v_materialSize 和 $v_pcs
String[] materialSizeAndPcs = v_materialSize_pcs.split(",");
String v_materialSize = materialSizeAndPcs[0];
String v_pcs = materialSizeAndPcs[1];
// 最终生成的MySQL语句
String mysql_sql = add_sql.replaceFirst("detail", "detail_mysql");
```
请注意,上述代码仅是将SQLite插入语句转换为MySQL语句的一种方法。在实际应用程序中,您需要根据需要进行适当的更改,例如处理数据类型差异和处理插入错误等。
function methord_handler_freight_Dispatch(value, row, index) { //弹框的url let url = $.acooly.framework.buildCanonicalUrl('/manage/platform/baseFreightForwarder/baseFreightForWard.html', null); var saveBtn = { id: 'loading-port-select-btn', text: '<i class="fa fa-lg fa-fw fa-col fa-check" ></i>确定', handler: function () { getFreightForward(); } }; 如何将getFreightForward当成参数
您可以将 `getFreightForward` 函数作为匿名函数的参数传递,并在匿名函数中调用 `getFreightForward` 函数。具体实现方法如下:
```
function methord_handler_freight_Dispatch(value, row, index) {
let url = $.acooly.framework.buildCanonicalUrl('/manage/platform/baseFreightForwarder/baseFreightForWard.html', null);
var saveBtn = {
id: 'loading-port-select-btn',
text: '<i class="fa fa-lg fa-fw fa-col fa-check" ></i>确定',
handler: function () {
// 在这里调用 getFreightForward 函数
getFreightForward();
}
};
// 将 saveBtn 对象作为参数传递给其他函数
otherFunction(saveBtn);
}
```
在这个示例中,我们将 `getFreightForward` 函数作为匿名函数的参数传递给 `saveBtn.handler` 属性,然后在匿名函数中调用了 `getFreightForward` 函数。最后,我们将 `saveBtn` 对象作为参数传递给了 `otherFunction` 函数。
阅读全文