none
Custom Data Grid work item control

    Frage

  • hi,

    I created a custom workitem control that is a data grid. There 5 cells and it can have multiple rows of data. What I cannot figure out is how to save the data when I save the work item. Can some one show me what I should be doing. Is this possible to have this type of custom control? I would assume so, but I am missing something that is probably straight forward. Can someone help me out with a sample?


    Paul Hacker
    Freitag, 22. Oktober 2010 12:34

Antworten

  • Hi Paul,

    WorkItem Schema does not have such as DataGrid field type, a workaround it to store it as PlainText and parse it yourself.

    For example, you can store the rows in data grid as

    <DataGrid>
    <Rows>
    <Row>
     <Column>Value1</Column>
     <Column>Value2</Column>
    ...
    </Row>
    ...
    </Rows>
    </DataGrid>
    
    

    Best regards,
    Ruiz


    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Als Antwort markiert Paul Hacker Donnerstag, 28. Oktober 2010 20:33
    Montag, 25. Oktober 2010 06:33
    Moderator

Alle Antworten

  • Hi Paul,

    WorkItem Schema does not have such as DataGrid field type, a workaround it to store it as PlainText and parse it yourself.

    For example, you can store the rows in data grid as

    <DataGrid>
    <Rows>
    <Row>
     <Column>Value1</Column>
     <Column>Value2</Column>
    ...
    </Row>
    ...
    </Rows>
    </DataGrid>
    
    

    Best regards,
    Ruiz


    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Als Antwort markiert Paul Hacker Donnerstag, 28. Oktober 2010 20:33
    Montag, 25. Oktober 2010 06:33
    Moderator
  • Would love to see a referenced implementation of this in the MSDN documentation around workitem customization.

    Montag, 25. Oktober 2010 18:51
  • As Ruiz mentioned, saving the result as plain text and parsing it yourself is a good way to implement this.  The "Test Case" work item has a custom grid (test steps) which stores its information as a single plain text field.

    Montag, 25. Oktober 2010 19:52
  • Rick....unless I'm mistaken the test case workitem "test steps" is a custom control and the source code/xml for the test steps control hasn't been released...so it's really difficult to figure out how to build a custom grid control when we don't have a referenced implementation.

    Would love to see see how they built the test steps control...

    Dienstag, 26. Oktober 2010 13:28
  • Hi Allen,

    I think you could look at any custom control example that reads/writes to a plain text field as a model.  Here's a page that describes building custom controls in case you're not familiar with the process.

    http://blogs.msdn.com/b/narend/archive/2006/10/02/how-to-use-custom-controls-in-work-item-form.aspx

    Let's say you choose structure your data for the custom control as XML and store it in a plain text field... At any point where you read the plain text value from the underlying work item field (e.g. InvalidateDataSource), you would parse the plain text value as XML and build a data model suitable for your grid.  While you're editing the work item the grid is working directly with your data model.  When it's time to write the plain text value to the underlying work item (e.g FlushToDatasource), you would build an XML stream from your data model, and save it to the work item as plain text.

    I can't put together a reference implementation at the moment, but I think this explanation might be enough to get you started.  Let me know if you have further questions.

    Thanks,
    Rick

    Dienstag, 26. Oktober 2010 17:38
  • Thanks for the information Rick. I'll look it over.

    I understand that you can't put together a reference implementation at the moment...but I sure hope someone from Microsoft can (in the not too distant future) put one together.

    It's these kinds of samples that help customers like me adopt TFS.

    Thanks!

    Mittwoch, 27. Oktober 2010 00:11
  • Rick, I've looked through the documentation but I'm just not understanding how exactly it's possible to build such a control.

    Are you or anyone from MSFT work on a reference implementation around this?

    Freitag, 19. November 2010 14:52
  • I started one but I can't commit to completing it and getting it published in the short term.   So for now let's see if we can determine where you're getting hung up.

    • The data from the grid can be stored in a single plain text WIT field as XML, as mentioned in Ruiz's post.  You choose whatever XML structure works for your data (and it doesn't even have to be XML for that matter).   WIT just sees this as a simple text string, your custom control understands how to interpret the string as structured data.
    • When your custom control reads data from the WIT field to populate the control (e.g. IWorkItemControl.InvalidateDataSource), it reads the simple string from the WIT field, parses the string and builds an appropriate model from the data... let's say something simple like a two dimensional array of Strings for the value of each cell.  Referring back to Ruiz's post, the data displayed in each cell of the grid would be the content of the <Column> tags.
    • Your custom control uses the data model to populate the data grid cells.
    • As you make changes in the grid, your custom control updates the data model, for example adding/removing rows, or changing existing value in a cell.  The changes are applied to your data model and WIT is not involved at this point.
    • When WIT asks you to update the field (e.g. IWorkItemControl.FlushToDataSource), you will take the data from your model and genreate a simple XML stream similar to that shown in Ruiz's post.    The XML is now a simple string.  You save this string in the WIT text field.

    So you can see that WIT has no knowledge of the structured data in this field, it's just a simple text field.  Your custom control has all the knowledge about the structure of the data contained in this string and is able to serialize and deserialize the data as needed to populate the control and save changes back to WIT.

    Can you post back with a specific question about what's not clear in this explanation?

    Thanks,
    Rick

    Freitag, 19. November 2010 16:53
  • Rick have you been able to work on this...would you have any code you could share? Would love to do the work to include an installer/documentation.
    Sonntag, 14. August 2011 20:16
  • Still looking. Bump++

    Dienstag, 29. November 2011 17:58
  • This thread is ~1.5 years old without a finished submission and YES, it'd be useful.  Furthering our TFS implementation via a pseudo/coded 1:many relationship of this nature would be EXTREMELY useful. 

    Mr. Rick Potts, PLEASE post your work for our consumption at a local TFS implementation (TFS 2010).  Thx!!

    • Bearbeitet SW TLI Montag, 9. April 2012 16:11
    Montag, 9. April 2012 16:10