Sunday, March 3, 2013

Itemdatabound of radgrid in javascript

function ResponseEnd() {
  Databound(); 
  }
$(document).ready(function (){

  var grid = $find("<%=rgMilestoneSummaryReport.ClientID %>");
    var MasterTable = grid.get_masterTableView();
    var Rows = MasterTable.get_dataItems();
    //alert(Rows.length);
    if(Rows.length>0){
       Databound();
    }
});
function Databound()
{
     var grid = $find("<%=rgMilestoneSummaryReport.ClientID %>");
    var MasterTable = grid.get_masterTableView();
    var selectedRows = MasterTable.get_dataItems();
    for (var i = 0; i < selectedRows.length; i++) {
      var row = selectedRows[i];
      var cell = MasterTable.getCellByColumnUniqueName(row, "IsResource");
      var cell1 = MasterTable.getCellByColumnUniqueName(row, "YTBR");
      var cell2 = MasterTable.getCellByColumnUniqueName(row, "NoOfInvoicesRaised");
      var cell3 = MasterTable.getCellByColumnUniqueName(row, "NoOfInvoicesPaid");
//      var cell4 = MasterTable.getCellByColumnUniqueName(row, "NoOfInvoicesPaid");
      var cell5 = MasterTable.getCellByColumnUniqueName(row, "ProjectName");
      if(cell.innerHTML=="Yes" && cell1.innerHTML=="0")
      {
        cell5.style.backgroundColor="red";
      }
     if(cell2.innerHTML==cell3.innerHTML)
     {
        if(cell2.innerHTML!=0 && cell3.innerHTML!=0)
        {
            cell3.style.backgroundColor="green";
        }
     }
     else
     {
        cell3.style.backgroundColor="red";
     }
     
      //here cell.innerHTML holds the value of the cell   
    }
}

when using ajaxpanel

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1"
    ClientEvents-OnRequestStart="onRequestStart" ClientEvents-OnResponseEnd="ResponseEnd">


No comments:

Post a Comment