Thursday, April 25, 2013

Get column name from radgrid of telerik in an array

function GetColumnNames()
        {
         var grid = $find("<%=RadGrid1.ClientID %>"); 
         var columnCount = grid.get_masterTableView().get_columns().length;
         var Colname=new Array();
         for(var i=0;i<columnCount;i++)
         {
         var UniqueName=grid.get_masterTableView().get_columns()[i].get_uniqueName();
         Colname[i]=UniqueName;
         }
        }

textbox key press by jQuery

Jquery
$(document).ready(function(){
var keypress_count1 = 0;
$("#txt_onkeypress").keypress(function(){
    keypress_count1++;   
  document.getElementById("<%=Label1.ClientID %>").innerHTML=document.getElementById("name_onkeypress").value;
});
});

HTML
<input type="text" id="txt_onkeypress" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>


Wednesday, April 10, 2013

Html Exporting Radgrid

The purpose of this event is to allow the developer to insert global styles (CSS) or configuration options (XML) to the exported file. A possible application for this event is to enable the grid lines for the current worksheet:

protected void Radgrid1_HTMLExporting(object sender, GridHTMLExportingEventArgs e)
    {
        e.Styles.Append("body { border:solid 0.1pt #CCCCCC; }");
    }

For More Information

http://www.telerik.com/help/aspnet-ajax/grid-html-export.html

Friday, April 5, 2013

Wednesday, April 3, 2013

Get QueryString By Javascript

    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);       
        var vars = query.split("&");
                
        for (var i=0;i<vars.length;i++)
        {  
            var pair = vars[i].split("=");                                       
            if (pair[0] == variable)
            {
                return pair[1];
            }
        }
    }


to get

var Str = getQueryVariable("QueryStringName");

Wednesday, March 20, 2013

Clear radgrid selected row by client side

 var masterTable = $find("<%=Radgrid1.ClientID%>").get_masterTableView();
    masterTable.clearSelectedItems();

Monday, March 11, 2013

Merge cell in radgrid

protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
                      for (int rowIndex =  RadGrid1.Items.Count - 2; rowIndex >= 0; rowIndex--)
        {
            GridDataItem row =  RadGrid1.Items[rowIndex];
            GridDataItem previousRow =  RadGrid1.Items[rowIndex + 1];

            for (int cellIndex = 0; cellIndex < row.Cells.Count; cellIndex++)
            {
                if (row.Cells[cellIndex].Text == previousRow.Cells[cellIndex].Text)
                {
                    row.Cells[cellIndex].RowSpan = previousRow.Cells[cellIndex].RowSpan < 2 ? 2 :              previousRow.Cells[cellIndex].RowSpan + 1;
                    previousRow.Cells[cellIndex].Visible = false;
                }
            }
        }
    }

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">