We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid - status column want to show different font color and different backgrod color

Thread ID:

Created:

Updated:

Platform:

Replies:

128032 Dec 28,2016 04:26 AM UTC Jan 3,2017 06:43 AM UTC ASP.NET Web Forms 3
loading
Tags: Grid
Pratheep
Asked On December 28, 2016 04:26 AM UTC

Hi

load / add /edit grid record status column ,how to show different font color and different background color ?

status - completed,new,process

private void BindDataSource()

{

if ((List<Products>)Session["DialogDataSource"] == null)

{

product.Add(new Products(10001, "ALFKI","completed"));

product.Add(new Products(10002, "ANATR", "new"));

product.Add(new Products(10003, "WERSDD", "process"));

}

else

{

product = (List<Products>)Session["DialogDataSource"];

}

this.ProductGrid.DataSource = product;

this.ProductGrid.DataBind();

}


protected void EditAction(string eventType, object record)

{

List<Products> data = Session["DialogDataSource"] as List<Products>;

Dictionary<string, object> KeyVal = record as Dictionary<string, object>;

if (eventType == "endEdit")

{

Products value = new Products();

foreach (KeyValuePair<string, object> keyval in KeyVal)

{

if (keyval.Key == "Productcode")

{

value = data.Where(d => d.Productcode == (int)keyval.Value).FirstOrDefault();

value.Productcode = Convert.ToInt32(keyval.Value);

}

else if (keyval.Key == "Productname")

value.Productname = Convert.ToString(keyval.Value);

else if (keyval.Key == "status")

value.status = Convert.ToString(keyval.Value);

}

}

else if (eventType == "endAdd")

{

Products newRecord = new Products();

foreach (KeyValuePair<string, object> keyval in KeyVal)

{

if (keyval.Key == "Productcode")

newRecord.Productcode = Convert.ToInt32(keyval.Value);

else if (keyval.Key == "Productname")

newRecord.Productname = Convert.ToString(keyval.Value);

else if (keyval.Key == "status")

newRecord.status = Convert.ToString(keyval.Value);

}

data.Insert(0, newRecord);

}

else if (eventType == "endDelete")

{

foreach (KeyValuePair<string, object> keyval in KeyVal)

{

if (keyval.Key == "Productcode")

{

Products value = data.Where(d => d.Productcode == (int)keyval.Value).FirstOrDefault();

data.Remove(value);

}

}

}

Session["DialogDataSource"] = data;

this.ProductGrid.DataSource = data;

this.ProductGrid.DataBind();

}


Thanks
Pratheep




Attachment: WebApplication1_2e767a9c.rar

Mani Sankar Durai [Syncfusion]
Replied On January 2, 2017 12:05 PM UTC

Hi Pratheep, 

Thanks for contacting Syncfusion support, 

We have analyzed your query and we can achieve your requirement by using QueryCellInfo event in grid. We have also prepared a sample that can be downloaded from the below link. 


Please refer the below code example. 

[workorder.aspx] 
  <ej:Grid ID="ProductGrid" ClientIDMode="Static" runat="server" AllowPaging="True" AllowFiltering="false" OnServerEditRow="EditEvents_ServerEditRow" 
                    OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow"> 
                  
  <ClientSideEvents ActionComplete="complete" QueryCellInfo="querycellinfo"  EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit" /> 
                                      <Columns> 
                   
</Columns> 
                         ... 
                </ej:Grid>            
 
<script type="text/javascript"> 
        function querycellinfo(args) { 
            var grid = $('#<%= ProductGrid.ClientID %>').ejGrid("instance"); 
            if (args.text == "completed") { 
                args.cell.style.color = "black"; 
                args.cell.style.background = "orange"; 
            } 
            else if (args.text == "new") { 
                args.cell.style.color = "white"; 
                args.cell.style.background = "green"; 
             ... 
            }  
        } 
</script> 

From the above code example we have changed the background color and particular text color using queryCellInfo event in grid. 
Please refer the documentation link. 
  
Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


Pratheep
Replied On January 3, 2017 12:39 AM UTC

Hi Manisankar Durai

Thank you for your support.Working fine

Thanks
Pratheep



Mani Sankar Durai [Syncfusion]
Replied On January 3, 2017 06:43 AM UTC

Hi Pratheep, 

Thanks for your feedback. 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;