refs:
https://stackoverflow.com/questions/18144142/jquery-ui-datepicker-with-angularjs
https://stackoverflow.com/questions/30296406/using-angular-bootstrap-datepicker-inside-of-ui-grid-unstable-3-0-0
https://angular-ui.github.io/bootstrap/
https://www.formget.com/angular-link-function/
http://www.cnblogs.com/TiestoRay/p/5085721.html
http://ui-grid.info/docs/#!/tutorial
最近需要对uigrid的cell编辑客制化,一个是日期时间的选择,一个是2级菜单的选择。
1)时间日期uigrid自带date的选择,没有时间,angular版bootstrap带日期时间,但是不太好看(挺大的界面,时间选择却很小),其他jquery有angular的实现也不太喜欢,关键其他位置已经有一个WdatePicker的使用,为界面和谐,所以继续使用这个控件。
纯粹的使用没有问题,当放入cell中时会出现编辑完成后不会自动回到编辑完成状态,为此,参考了
https://stackoverflow.com/questions/30296406/using-angular-bootstrap-datepicker-inside-of-ui-grid-unstable-3-0-0
中的实现,主要是点击windows其他位置接收编辑。
同时对input的click事件和wdatepicker的选择完成事件做了处理,该方法出入了dp来获取当前时间,用cellNav来获取当前cell。
var rowCol = $scope.gridApi.cellNav.getFocusedCell();
if (rowCol !== null) {
//$scope.currentFocused = 'Row Id:' + rowCol.row.entity.id + ' col:' + rowCol.col.colDef.name;
var cc=rowCol.col.column
console.log("get :" + 'Row Id:' + rowCol.row.entity.id + ' col:' + rowCol.col.colDef.name + ' pre_donetime:' + rowCol.row.entity.pre_donetime + " dp:" + dp.cal.getNewDateStr());
var oldVal = rowCol.row.entity.pre_donetime;
var newVal = dp.cal.getNewDateStr();
var dtOld = (new Date(oldVal)).format("yyyy-MM-dd HH:mm:ss");
var dtNew = (new Date(newVal)).format("yyyy-MM-dd HH:mm:ss");
console.log("oldDate:" + dtOld)
console.log("newDate:" + dtNew)
if (dtNew !== dtOld) {
rowCol.row.entity.pre_donetime = dtNew;
//$scope.gridApi.edit.raise.afterCellEdit(rowCol.row.entity, rowCol.col.colDef, dtNew, dtOld);
}
}
不是很完美,如果能在 uiGridEditDatepicker 的directive中实现就更好了。
2)下拉列表二级选择框,uigrid自带一级dropdownlist,无法满足当前状态。所以,新建一个页面做这个事情,用top.artDialog 方式似乎很难获取返回值,所以参考了angular的boostrap版本,其中有很多modal模板,已经说明,
https://angular-ui.github.io/bootstrap/
这种内嵌在html中type="text/ng-template"方式,成功把2个页面合并成了一个页面。