小编Tom*_*olo的帖子

带有唯一选择的物料复选框

在我的angular2 + bootstrap + material项目中,我在这个问题上挣扎了2天。

我需要更改材料设计复选框:

  • 当我从表格中选中一个复选框时,该复选框必须是唯一的一个

我知道我可以使用一个实质性的单选按钮,但是在那种情况下,我还有另一个问题:我无法取消选中该单选按钮。

因此,我需要启用唯一检查以及检查/取消检查功能。

在此处输入图片说明

我尝试了以下

  • 与document.getElement.blablabla与dom互动
  • 角度的二手dom插值
  • Javascript功能
  • jQuery函数

这是html 的代码

<div class="row">
<div class="col-lg-12">
    <label>Ordini cliente</label>
    <mat-table #table [dataSource]="dataSource">

        <!--- Note that these columns can be defined in any order.
              The actual rendered columns are set as a property on the row definition" -->

        <!-- Select Column -->
        <ng-container matColumnDef="Select">
            <mat-header-cell *matHeaderCellDef></mat-header-cell>
            <mat-cell *matCellDef="let item"><mat-checkbox color="primary"></mat-checkbox></mat-cell>
        </ng-container>


        //OTHER COLUMNS ...

        <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
        <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
    </mat-table>


</div>
Run Code Online (Sandbox Code Playgroud)

我的想法是将元素绑定到这样的click事件

<mat-cell *matCellDef="let …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery dom angular

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

Angular(4.xx)Material CheckBox组件(mat-checkbox):[checked]无效

怎么可能????

看到这个:

<div class="col-lg-1 check-field">
    <mat-checkbox color="primary"
                  [checked]="true"
                  formControlName="flagRimb">Rimb.
    </mat-checkbox>
</div>
Run Code Online (Sandbox Code Playgroud)

我已经把真正的价值放在了检查上,并且仍然没有看到在加载组件时检查了mat-checkbox !! 难以置信!!!

唯一可以扰乱行为的是formControl,它有:

     return this._formBuilder.group({
        [...],
        flagAdd : ['',Validators.required],
        [...]
    });
Run Code Online (Sandbox Code Playgroud)

formControlName就在那里,因为我需要设置相对于http rest调用给出的model.value的复选框值,但即使默认值设置为true也不行!

从控制台看来,生成的爆炸材料html不会从<_ <继承checked属性.

任何的想法?提前致谢!!

编辑1:已使用已检查INSTEAD [已选中]

在此输入图像描述

javascript forms checkbox material angular

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

SpringBoot 测试模块不会在正确的类路径中搜索 log4j2 配置

我在 SpringBoot 项目中运行测试时遇到了一些问题。

项目结构如下:

项目结构图

我可以毫无问题地启动 resourceService,但是如果我什至尝试运行 SpringBoot 项目的标准测试......

package com.pcsystem;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class ResourceserviceApplicationTests {

    @Test
    public void contextLoads() {
    }

}
Run Code Online (Sandbox Code Playgroud)

程序响应此错误:

Logging system failed to initialize using configuration from 'resourceservice/log4j2.xml'
java.io.FileNotFoundException: C:\java\IntelliJ_projects\baseprojectoauth2\resourceservice\resourceservice\log4j2.xml (Unable to find the specified classpath)
Run Code Online (Sandbox Code Playgroud)

所以我试图改变 application.properties 的特定属性

logging.config=resourceservice/log4j2.xml
Run Code Online (Sandbox Code Playgroud)

logging.config=log4j2.xml
Run Code Online (Sandbox Code Playgroud)

更改后,我注意到 resourceserviceApplication 将无法启动,因为它找不到 log4j2.xml:

Logging system failed to initialize using configuration from 'log4j2.xml'
java.io.FileNotFoundException: C:\java\IntelliJ_projects\baseprojectoauth2\log4j2.xml (Unable to find the specified classpath)
Run Code Online (Sandbox Code Playgroud)

我尝试通过多种方式解决问题并进行了大量研究,但目前我仍然被困在这里。

任何的想法?

ps:似乎 …

java testing logging log4j2 spring-boot

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

APACHE POI 4.1:从十六进制代码设置单元格背景颜色

我尝试了在堆栈溢出上发布的不同解决方案,以将背景颜色应用于 Apache POI 生成的单元格,但没有任何效果。

我正在做类似的事情:

Workbook workbook = new XSSFWorkbook(); 
Sheet sheet = workbook.createSheet(sheetName);

XSSFCellStyle cellStyle = ((XSSFCellStyle) workbook.createCellStyle());

if (styleObject.getBgColor() != null) {
    java.awt.Color javaBdgColor = java.awt.Color.decode(voceStyle.getBgColor()); // this is #FFF000
    XSSFColor bgColor = new XSSFColor(javaBdgColor, new DefaultIndexedColorMap());
    cellStyle.setFillForegroundColor(bgColor.getIndex());
    cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
}

Row newRow = Rowsheet.createRow(0);
Cell newCell = newRow.createCell(0);
newCell.setCellStyle(cellStyle);

// write file
String pathFileExport = buildPathExportFile("test-export");
FileOutputStream fileOut = new FileOutputStream(pathFileExport);
workbook.write(fileOut);
fileOut.close();

//close workbook
workbook.close();

return Paths.get(pathFileExport);
Run Code Online (Sandbox Code Playgroud)

我认为我的代码中一切正常,但每个单元格样式都会导致黑色背景。 黑细胞

我对没有字段的调试结果期间的“DefaultIndexedColorMap”实例有一些疑问:

代码调试器

在这一点上,我不确定该怎么做才能解决。其他帖子中的每个人似乎都能正常工作,但我的背景仍然是深色而不是黄色。

有什么建议?提前致谢!

java spring colors apache-poi apache-poi-4

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