0

共有ポイント コントロールを使用して、ガント チャート ジェネレーターを作成しようとしています。

<Sharepoint:JsGrid>

このチュートリアルに従いました:方法: JS グリッド コントロールを使用してガント チャートを作成する

また、Sharepoint TaskList をデータ ソースとしてリンクしました。

XML を使用してフィルターのシステムを開発しました。

しかし、今は前任者を管理し、依存関係を矢印で表現したいと考えています。

それらを管理するために、EnableGantt 関数 ( ganttDependentsColumnName) の最後のパラメーターを使用しました。これには、依存関係情報を含む列の名前が必要です。

この列には何を入力する必要がありますか?

私が試みたのは、先行タスクを含む DataRow のレーンであるタスクの ID で埋めることであり、クラス Dependency のオブジェクトを配置しようとしました。

class Dependency : IJsonSerializable
{
    public object Key {get; set;} // RecordKey
    public LinkType{get; set;} //LinkType

    public string ToJson(Serializer s)
    {
        return JsonUtility.SerializeToJsonFromProperties(s,this);
    }
}

(このコードはチュートリアルの回答からのものです)

キーには、何を入れなければなりませんか? 誰かがそれをやった、またはそれを行う方法を知っていれば、それはいいかもしれません.

4

1 に答える 1

1

あなたがまだこの問題に直面しているかどうかわからない。しかし、これは私たちがPredecessorsコラムのためにしたことであり、これは私がこれを理解している限りです:

1] Dependencyクラスを少し変更して、示されているようにコンストラクターを追加します(そうでない場合はエラーになります)。

2]次に、基本的にDependency配列をPredecessors列に渡す必要があります。つまり、JSGridコントロールは、依存関係の開始点/行と終了点/行を認識する必要があります(したがって、配列が必要です)。ToJsonJSONシリアル化は、継承とメソッドのためにすでに処理されているため、心配する必要はありません。

コード:

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リンクタイプが正しい行と一致し、タスクが正しいタスク開始日とタスク終了日、および先行キーとともに正しくリストされていることを確認してください。

于 2012-07-17T05:17:52.877 に答える