Sharepoint 列表中的按钮 - 条件可见性
Button in Sharepoint list - conditional visibility
我正在尝试创建一个仅在“Zapůjčeno”列为空时出现的按钮。
{
"elmType": "button",
"txtContent": "Odeslat Žádost",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"7347b7be-696f-46c8-bae8-78c230a354b3\"}"
},
"style": {
"background-color": "#03A9F4",
"color": "white",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "!=",
"operands": [
"[$ID]",
"1"
]
},
"hidden",
"visible"
]
}
}
}
Example with "ID" column
如果我尝试使用默认列“ID”,它会起作用,但如果我想使用我的列“Zapůjčeno”,它就不起作用。
感谢您的指教,我是 SharePoint 的新手。
Zapůjčeno 列的内部名称是否与显示名称相同?您可以在 list/library settings 中查看该列的内部名称,然后单击该列名称。此列的内部名称将在 URL.
中
我想你可以使用这样的东西:
{
"elmType": "button",
"txtContent": "= if([$Zapůjčeno_Internal_Name]=='','Odeslat Žádost', '')",
"customRowAction": {
"action": "executeFlow",
"actionParams": "='{\"id\": \"' + if([$Zapůjčeno_Internal_Name]=='','7347b7be-696f-46c8-bae8-78c230a354b3','') + '\"}'"
},
"style": {
"background-color": "#03A9F4",
"color": "white",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "!=",
"operands": [
"[$ID]",
"1"
]
},
"hidden",
"visible"
]
}
}
}
正如@Rikking 所说,您需要使用 json 中的内部名称。
我的测试专栏格式json供大家参考:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children":[
{
"elmType":"button",
"style":{
"background-color":"=if([$Zap_x016f_j_x010d_eno]=='','lightblue','')",
"width":"80px",
"height":"50px",
"display":"=if([$Zap_x016f_j_x010d_eno]=='','','none')"
},
"txtContent":"=if([$Zap_x016f_j_x010d_eno]=='','Odeslat Žádost','')"
}
]
}
测试结果:
Zap_x016f_j_x010d_eno 是 Zapůjčeno 的内部名称,我的 SharePoint Online 的默认语言是英语。
我正在尝试创建一个仅在“Zapůjčeno”列为空时出现的按钮。
{
"elmType": "button",
"txtContent": "Odeslat Žádost",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"7347b7be-696f-46c8-bae8-78c230a354b3\"}"
},
"style": {
"background-color": "#03A9F4",
"color": "white",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "!=",
"operands": [
"[$ID]",
"1"
]
},
"hidden",
"visible"
]
}
}
}
Example with "ID" column
如果我尝试使用默认列“ID”,它会起作用,但如果我想使用我的列“Zapůjčeno”,它就不起作用。
感谢您的指教,我是 SharePoint 的新手。
Zapůjčeno 列的内部名称是否与显示名称相同?您可以在 list/library settings 中查看该列的内部名称,然后单击该列名称。此列的内部名称将在 URL.
中我想你可以使用这样的东西:
{
"elmType": "button",
"txtContent": "= if([$Zapůjčeno_Internal_Name]=='','Odeslat Žádost', '')",
"customRowAction": {
"action": "executeFlow",
"actionParams": "='{\"id\": \"' + if([$Zapůjčeno_Internal_Name]=='','7347b7be-696f-46c8-bae8-78c230a354b3','') + '\"}'"
},
"style": {
"background-color": "#03A9F4",
"color": "white",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "!=",
"operands": [
"[$ID]",
"1"
]
},
"hidden",
"visible"
]
}
}
}
正如@Rikking 所说,您需要使用 json 中的内部名称。
我的测试专栏格式json供大家参考:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children":[
{
"elmType":"button",
"style":{
"background-color":"=if([$Zap_x016f_j_x010d_eno]=='','lightblue','')",
"width":"80px",
"height":"50px",
"display":"=if([$Zap_x016f_j_x010d_eno]=='','','none')"
},
"txtContent":"=if([$Zap_x016f_j_x010d_eno]=='','Odeslat Žádost','')"
}
]
}
测试结果:
Zap_x016f_j_x010d_eno 是 Zapůjčeno 的内部名称,我的 SharePoint Online 的默认语言是英语。