javascript - 甘特图中的 Sharepoint 脚本 webpart 不起作用
问题描述
我不明白为什么,但我在sharepoint上从ms项目构建了甘特图,有很多子任务,我想默认隐藏子任务。
不幸的是,我放在甘特图上方的任何脚本都不起作用并产生任何东西......
我尝试了每种类型的链接,没有任何工作......我无法理解问题..我尝试了这里解释的内容,使用该代码:为什么这个 jQuery 在我的 Sharepoint 页面上不起作用? 但没有任何工作在此处输入图像描述
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script>
jQuery(document).ready(function(){
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', run);
});
function run(){
jQuery('div[class="ms-vb itx"]').find('span[style]').each(function(){
if(jQuery(this).css('margin-left')!="0px"){
jQuery(this).parent().parent().parent().hide();
}
});
}
</script>
谢谢
解决方案
我在新站点上重新安装了所有内容,现在可以正常工作了……非常奇怪的问题。
我想知道是否也可以更改任务列表视图中的格式:
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"elmType": "div",
"attributes": {
"class": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"No Issues"
]
},
"sp-field-severity--good",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Inactive"
]
},
"sp-field-severity--low",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Warning"
]
},
"sp-field-severity--warning",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"In Review"
]
},
"sp-field-severity--severeWarning",
"sp-field-severity--blocked"
]
}
]
}
]
}
]
}
},
"children": [
{
"elmType": "span",
"style": {
"display": "inline-block",
"padding-left": "4px"
},
"attributes": {
"iconName": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"No Issues"
]
},
"CheckMark",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Inactive"
]
},
"Forward",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"In Review"
]
},
"Error",
{
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"@currentField",
"Warning"
]
},
"Warning",
"ErrorBadge"
]
}
]
}
]
}
]
}
}
},
{
"elmType": "span",
"txtContent": "@currentField",
"style": {
"padding-left": "10px",
"font-weight": "bold"
}
}
]
}
使用类似的东西(此代码正在使用列表,但不适用于列出任务的应用程序,不明白为什么)
推荐阅读
- python - 调整 x 轴大小并保存信息
- reactjs - TS React 数据导入:“TS2322:类型 '{ data: { key1: string; }; }' 不可分配给类型 'IntrinsicAttributes & Props'。”
- c - 如何使用 dart ffi 为给定的 C 结构编写绑定?
- java - 使用for循环并行化函数
- javascript - 如何在 firestore 触发的函数中写入 firestore?
- django - 找不到 Django 模板 - 尝试了不同的位置
- feathersjs - 羽毛唯一的客户ID?
- git - 用于微服务和部署的单一 GIT 存储库
- python - 我正在尝试保存我所做的聚类结果并显示此错误消息“int”对象不可下标
- angular - Azure AD B2C:不支持请求中提供的范围“user.read”