あなたがまだこの問題に直面しているかどうかわからない。しかし、これは私たちがPredecessors
コラムのためにしたことであり、これは私がこれを理解している限りです:
1] Dependencyクラスを少し変更して、示されているようにコンストラクターを追加します(そうでない場合はエラーになります)。
2]次に、基本的にDependency
配列をPredecessors
列に渡す必要があります。つまり、JSGridコントロールは、依存関係の開始点/行と終了点/行を認識する必要があります(したがって、配列が必要です)。ToJson
JSONシリアル化は、継承とメソッドのためにすでに処理されているため、心配する必要はありません。
コード:
1]依存関係クラス:
public class Dependency : IJsonSerializable
{
public object Key { get; set; } // recordKey
public LinkType Type { get; set; } // SP.JsGrid.LinkType
public Dependency() {
Key = DBNull.Value;
Type = LinkType.FinishStart;
}
public string ToJson(Serializer s)
{
return JsonUtility.SerializeToJsonFromProperties(s, this);
}
}
2] SharePointタスクリスト(データはDataTableのオブジェクト)を対象としない場合は、列を追加します。
data.Columns.Add(new DataColumn("Predecessors",typeof(Dependency[])));
3]右側のオブジェクト配列をPredecessors
列に設定します。
if (<<A predecessor exists>>){
Dependency[] dep = new Dependency[2];
dep[0] = new Dependency();
try{
/*
// Unique Identifier for your row based on what you are
// passing to the GridSerializer while initializing it
// (as a third parameter which is called keyColumnName)
// In my case I had to get it by doing some coding as
// shown. The first object in the array represents the
// previous row and so the unique identifier should
// point to the previous row
*/
dep[0].Key = (
data.Select(
"ID=" +
data.Rows[s]["PredecessorsID"].ToString()
)
[0]["Key"]
);
}catch (Exception ex){
dep[0].Key = DBNull.Value;
}
dep[0].Type = LinkType.FinishStart;
/*
// Unique Identifier for your row based on what you are
// passing to the GridSerializer while initializing it
// (as a third parameter which is called keyColumnName)
// In my case I had to get it by doing some coding as
// shown. The second object in the array represents the
// current row and so the unique identifier should
// point to the current row
*/
dep[1] = new Dependency();
try{
dep[1].Key = data.Rows[s]["Key"];
}catch (Exception ex){
dep[0].Key = DBNull.Value;
}
dep[1].Type = LinkType.StartFinish;
data.Rows[s]["Predecessors"] = dep;
}
最後に、関数Predecessors
の呼び出し中に列を渡します。EnableGantt()
gds.EnableGantt(
Convert.ToDateTime(
dr["start Date"]
),
Convert.ToDateTime(
dr["Due Date"]
),
GanttUtilities.GetStyleInfo(),
"Predecessors"
);
StartFinishリンクタイプとFinishStartリンクタイプが正しい行と一致し、タスクが正しいタスク開始日とタスク終了日、および先行キーとともに正しくリストされていることを確認してください。