Alternate Row colors when using a template
Last Post 07-03-2013 07:36 AM by Ryan Bakerink. 5 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
Scott PetersonUser is Offline
skipping stones
skipping stones
Posts:11
Avatar

--
07-01-2013 10:58 AM
    I would very much appreciate if you could let me know I could alternate my row colors when using a template to define the output, assuming this is possible.

    I did find an article on your web site http://www.datasprings.com/news/blo...row-colors that seems to hint this is possible.  This example does not make sense to me as I do not know what "TemplateID" refers to.

    any help would be appreciated.
    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    07-01-2013 02:19 PM
    Hello Scott,

    TemplateID was only the Primary Key of the table in the example/blog.

    So you should replace TemplateID with the ColumnName of your Sorting Column:

    (CASE WHEN ABS(TemplateID) % 2 = 1 THEN '#F6F6F6' ELSE '#E8E8E8' END) As TheRowColor

    If you had a column named LastName and was using that as the sorting column of your Dynamic View, I would recommend using the following SQL Query:

    Select
    (CASE WHEN ABS(LastName) % 2 = 1 THEN '#F6F6F6' ELSE '#E8E8E8' END) As TheRowColor

    This gets you an alternating row color based on the sorting field.

    Please let me know if you have any questions.

    Thanks,

    Ryan
    Scott PetersonUser is Offline
    skipping stones
    skipping stones
    Posts:11
    Avatar

    --
    07-01-2013 06:09 PM

    Ryan,

    Thank you for the quick response.

    I am not sure how this would work on a column that consists of string data?  I am not an SQL expert but ABS returns the absolute value of a number.

    At any rate I would be fine to just see it working on primary key.  I can see where this would work if the ID's were in sequence and the data was not getting filtered.  I am not sure I follow the command 100% but it seems like it is determining if the ID is odd or even.

    In my table the ID's are not in seq. order.  in my case I get lots of rows having the same color in a row.

    I can see that the module can show a rowID and if I could work with that in this same (or similar fashion) then I could see where it would work well.

    I hope you might have another suggestion or question for me.

    Thank you.

    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    07-02-2013 12:50 PM
    Hello Scott,

    If you're not using a sequential identity for your Primary key, I would recommend doing the following:


    Select
    (CASE WHEN ABS(Row_Numer() over(order by ValidColumnName)) % 2 = 1 THEN '#F6F6F6' ELSE '#E8E8E8' END) As TheRowColor


    ValidColumnName = Provide a column name that's accessible in the table you're connecting to.

    Please let me know if this helps.

    Thanks,

    Ryan
    Scott PetersonUser is Offline
    skipping stones
    skipping stones
    Posts:11
    Avatar

    --
    07-03-2013 07:24 AM

    Thank you! the new SQL statement works very well.

    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    07-03-2013 07:36 AM
    Great to hear.

    Please let us know if you ever have any questions.

    Thanks,

    Ryan


    ---
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi