Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted on Jun 04, 2008 04:57
open dhtmlx forum
Set skin through XML

Hi,
I would like to set skin of the grid through XML and based on the skin selected i would like to do some changes in the values. How can i acheive the functionality.
i.e. If i select the skin to be XP then i would like to set the rows of the grid to be green.

Syntax that i am making use of
    Response.Write "<script type=""text/javascript"">"
    Response.Write "<div style=""margin:20px;"">"
    Response.Write "Choose skin to apply:"
    Response.Write "<select onchange=""mygrid.setSkin(this.value)"">"
    Response.Write "<option value=""gray"">gray"
    Response.Write "<option value=""mt"">mt"
    Response.Write "<option value=""xp"">xp"
    Response.Write "<option value=""clear"">clear"
    Response.Write "<option value=""modern"">modern"
    Response.Write "<option value=""light""selected>light"
    
    Response.Write "</select>"
    Response.Write "</div>"
If this.value=xp then
        SkinColor="green"
        end If
    Response.Write "</script>"

Is my syntax correct?
Answer posted by Support on Jun 04, 2008 05:05
You can execute any grid API command from afterInit section of XML

<rows>
    <head>
       ... configuration of grid here...
       <afterInit><call command="setSkin"><param>xp</param></call></afterInit>
    </head>
... any data here
</rows>

The look of grid for each skin can be adjusted in dhtmlxgrid.css , please check
    http://www.dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Creating_custom_skin.html#grid_cust_skin
Answer posted on Jun 04, 2008 06:20

Hi,

Thanks for the reply.

I want to set the background color of the row in the grid as and when i change the skin of the grid. So, i want to set the values in the XML. I dont want to change the CSS file. Is this possible to acheive?

Suppose i change the skin of the grid to 'xp' then i want to set the background color of certain rows to 'Green'.

Similarly if i change the skin of the grid to 'light' then i want to set the background color of certain rows to 'red'.

How can i acheive the above mentioned functionality by using the syntax style as mentioned in my query earlier?

Answer posted by Support on Jun 05, 2008 05:49
There is no any inner event on skin changing , so you can't catch the moment indirectly
In case of direct coding you can use
    grid.setSkin(name)
    if (name=="xp"){
       grid.setRowColor(some,"green");
    }

The more elegant way is to define special css rules

In XML
        <row class="special" >....
In HTML
<style>
    .gridbox_xp .special{
       background-color:green !important;
    }
    .gridbox_light .special{
       background-color:red !important;
    }
</style>