locked
2012 way to format the cell of a datagrid RRS feed

  • Question

  • I have tried to search for this, and while I have found some previous posts, I don't know if I'm reading obsolete info.   I'm disappointed that there is not a more intuitive way to do this basic, common function:  programmatically changing the contents or format/font/color of a cell of a grid.

    Can someone point at the 2012, easiest way to do this?     Thank you.

    In ASP.NET land, one easy way was to use Labels and then use html inside the labels.  Is there not something analogous that is that simple?

    Tuesday, February 19, 2013 8:07 PM

All replies

  • This "How To" should show you how to do what you want.

    How to: Format Numbers and Dates


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Wednesday, February 20, 2013 12:21 AM
    Moderator
  • Thank you.

    But, that's a basic approach for number and date formatting.   I don't see how I would change the text contents of a cell, based on the contents, as well as do formatting for color/font based on contents of the cell.

    Wednesday, February 20, 2013 12:50 PM
  • Have you looked at my gallery sample to see if that will help do the job that you want?

    Control colors of DataGrid rows and other UI elements in LightSwitch

    "Control colors of DataGrid rows and other UI elements in LightSwitch"

    *** very wierd - I replied earlier to this thread and it ended up in a totally unrelated thread - better late then never ***


    Dave Baker | Xpert360 blog | twitter : @xpert360 Opinions are my own. Please mark as answer if this helps solve your problem.

    • Proposed as answer by babloo1436 Saturday, February 23, 2013 11:23 AM
    Thursday, February 21, 2013 9:55 PM
  • Dave - thank you very much for that post.

    I didn't find that sample when I was searching for an answer.  I will take a look.

    But between the this and the lack of a Calendar in a tool like this, I had to press the pause button on LS again for us.   Which greatly disappointed me.   I'll try again in another year or so.

    Friday, February 22, 2013 1:55 PM
  • Dave, can you confirm your solution works for LS2012?

    Whenever I copy your solution, line-for-line, my datagrid doesn't show the coloured rows on the first load of the screen.  Only after a refresh of the screen, or the datagrid.
    I need to put in a Table.Refresh() after adding the _LoadingRow handler, which obviously results in the screen loading slower (since the data in the grid is fetched twice).

    I tried to work out what is causing this, and it seems (on my system, at least) that the ControlAvailable event for the DataGrid is only firing AFTER the contents of the grid have been populated (i.e. AFTER the _LoadingRows would have occurred).

    Is this a LS2012 bug, or am I missing something obvious?


    Free Visual Studio LightSwitch extensions: Elyl's Extensions

    Friday, March 1, 2013 2:25 PM