小编Pra*_*tel的帖子

在选择模型角度中搜索后未选择以前的数据

我正在研究 angular selectionmodel,其中我有一个搜索栏,用户可以在其中搜索列表并选择项目,如果用户关闭搜索关键字,则是先前选择的值,即在搜索未在 selectionmodel 列表中被选中之前。

在 ts 中搜索代码

searchUsers(filterValue: string) {
  this.previousSelectedValues = this.userSelection.selected;
  console.log("came to searchUsers",filterValue);
  this.searchKey = filterValue;
  let params = { 'searchData': this.searchKey}
  this.commCenterService.getSearchedUsers(params).subscribe((res)=>{
    console.log("Search Response: Users",res);
    this.users = res;
    console.log("previous selected fields",this.userSelection.selected);
    if(filterValue == ""){
     this.previousSelectedValues.forEach(row => this.userSelection.select(row));
    }
    this.dataSource = new MatTableDataSource(this.users);
   });
}
Run Code Online (Sandbox Code Playgroud)

selectionmodel 初始化代码

userSelection = new SelectionModel<AddRecipientsList>(true, []);
/** Whether the number of selected elements matches the total number of rows. */
isAllSelected() {
  const numSelected = this.userSelection.selected.length;
  const numRows …
Run Code Online (Sandbox Code Playgroud)

selectionmodel angular-material angular

4
推荐指数
1
解决办法
4390
查看次数

如何清除select2下拉列表?

我正在处理一个要求,即在通过Ajax提交表单之后必须清除select2下拉框。我已经搜索并尝试了几种解决方案,但是没有用。

我的select2代码是:

$(document).ready(function(){
 $("#my_select_id").select2({
      placeholder: "Select One Option",
      allowClear: true,
      initSelection: function(element, callback) { }
 }); 
})
Run Code Online (Sandbox Code Playgroud)

清除select2的脚本是:

$('#my_select_id').select2("val", "");
Run Code Online (Sandbox Code Playgroud)

谁能告诉我这段代码有什么问题,谢谢。

jquery jquery-select2

2
推荐指数
1
解决办法
7196
查看次数

是否可以在使用 fputcsv 导出到 csv 时将标题文本加粗?

我正在处理导出到 csv 工作表的要求,其工作正常的数据正在导出到 CSV 工作表,但所有数据包括工作表顶部每列的标题和作为普通文本导出的普通数据。我在这里想要的是显然所有的标题都应该是粗体的。是否可以以粗体颜色导出所有标题?

我的代码:

$list[] = 'Title-1,Title-2,Title-3,Title-4'; // I want these titles in bold text
foreach ($result as $ck => $user_data) {
  $list[] = $user_data['val-1'] . ',' . $user_data['val-2'] . ',' . $user_data['val-3']. ',' . $user_data['val-4'];
}
ob_clean();
$fileName = 'file_name.csv';
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment;filename=' . $fileName);
$file = fopen("contacts.csv", "w");
$file = fopen('php://output', 'w');
foreach ($list as $line) {
  fputcsv($file, explode(',', $line));
}
fclose($file);
exit; …
Run Code Online (Sandbox Code Playgroud)

php export fputcsv export-to-csv

1
推荐指数
1
解决办法
6674
查看次数