All posts by friend31

TELERIK ASP.net AJAX TIPS

TELERIK ASP.net AJAX TIPS TIPS TIPS

 

Get RadGrid Selected Value Server Side

ASPX

 

<telerik:RadGrid ID=”rgData” runat=”server” EnableLinqExpressions=”false”

AutoGenerateColumns=”False”

GridLines=”None” enableajax=”false” >

<MasterTableView AllowPaging=”True” AllowSorting=”True”

GridLines=”None” DataKeyNames=”EntityID”>

<PagerStyle Mode=”NextPrevNumericAndAdvanced” />

<Columns>

<telerik:GridBoundColumn DataField=”EntityID” Display=”false” UniqueName=”EntityID”></telerik:GridBoundColumn>

<telerik:GridTemplateColumn HeaderText=”Entity Name”

DataField=”EntityName” UniqueName=”EntityName”

DataType=”System.String”>

<ItemTemplate>

<asp:label id=”lblEntityName” runat=”server” Text=’<%# DataBinder.Eval(Container, “DataItem.EntityName”) %>‘>

                                                                           </asp:label>

</ItemTemplate>

</telerik:GridTemplateColumn>

 

CODE BEHIND

 

else if (rgData.SelectedItems.Count == 1)

{

                GridDataItem dataItem = rgData.SelectedItems[0] as GridDataItem;

string strEntityID = “”

, strEntityName = “”;

 strEntityID = dataItem.GetDataKeyValue(“EntityID”).ToString();

                strEntityName = (dataItem.FindControl(“lblEntityName”) as Label).Text;

 

 

 

 

 

RadTreeView Client Side Single Node Selection

 

function rtvSelectorNodeChecked(sender, args) {

//single node check, uncheck others

var node = args.get_node();

if (node.get_checked() == true) {

var treeview = $find(“<%= this.rtvSelector.ClientID >”);

treeview.uncheckAllNodes();

node.check();

}

}

 

 

 

function rtvSelectorClientNodeChecked(sender, args) {

var node = args.get_node();

if (node.get_checked() == true) {

var treeview = $find(“<%= this.rtvSelector.ClientID %>”);

treeview.uncheckAllNodes();

node.check();

node.select();

}

 

}

function rtvSelectorClientNodeClicked(sender, args) {

var node = args.get_node();

if (node.get_category() == ‘DistinctItem’) {

var treeview = $find(“<%= this.rtvSelector.ClientID %>”);

treeview.uncheckAllNodes();

node.check();

node.select();

}

}

 

 

Refresh aspx page inside iframe of RadPageView

 

var pageWithTabs = null;

var multiPage = $find(“<%= radpMultiPage.ClientID %>”);

var pageView = multiPage.findPageViewByID(“<%= radpPageView.ClientID %>”);

 

$telerik.getChildrenByTagName(pageView.get_element(), “iframe”)[0].contentWindow.functionWithParameters(id1,id2,etc);

 

 

 

 

Set RadCombobox Value on Client Side

 

function SetResourceGroup(value) {

var combo = $find(‘<%= this.rcbControl.ClientID %>’);

var itm = combo.findItemByValue(value);

combo.clearSelection();

if (itm) {

itm.select();

}

 

}

 

 

 

//for readonly RadCombobox

 

function SetResourceGroup(value) {

var combo = $find(‘<%= this.rcbControl.ClientID %>’);

combo.enable();

var itm = combo.findItemByValue(value);

combo.clearSelection();

if (itm) {

itm.select();

}

combo.disable();

 

}

 

function pageLoad() {

var combo = $find(‘<%= this.rcbControl.ClientID %>’);

combo.disable();

}

 

 

 

 

 

 

 

 

 

 

 

 

RadGrid Client Side Select Row Get Keys and Cells Values

function selectVendor(sender, eventArgs)

{

 

var grid = sender;

var mtv  = grid.get_masterTableView();

var radGridRow = mtv.get_dataItems()[eventArgs.get_itemIndexHierarchical()];

 

//cell

var entityName = mtv.getCellByColumnUniqueName(radGridRow, “EntityName”).innerHTML;

 

//key

var id1 = radGridRow.getDataKeyValue(“id1”);

var id2 = radGridRow.getDataKeyValue(“id2”);

 

}

 

And don’t forget to put ClientDataKeyNames in RadGrid’s MasterTableView

e.g. ClientDataKeyNames=” id1, id2”

 

 

 

 

 

Hide unnecessary space for empty lblMessage

 

function pageLoad() {

var $ = $telerik.$;

if ($(“#<%= this.lblMessage.ClientID %>”).html() == ”) {

$(“#divMessage”).css(“height”, “0px”);

$(“#divFilter”).css(“top”, “23px”);

$(“#divGrid”).css(“top”, “152.04px”);

}

else {

$(“#divMessage”).css(“height”, “19px”);

$(“#divFilter”).css(“top”, “37px”);

$(“#divGrid”).css(“top”, “166.04px”);

}

}

 

 

 

 

RadCombobox dropdown list width

 

#<%= rcbControl.ClientID %>_DropDown{

width:500px !important;

}

 

 

 

 

Get selected grid rows count client

 

function rbtnDelete_Clicking(sender, args) {

var grid = $find(‘<%= this.radGridControl.ClientID %>’);

var mtv = grid.get_masterTableView();

var rows = mtv.get_selectedItems();

if (rows.length > 0) {

args.set_cancel(!window.confirm(“Are you sure you want to delete selected records?”));

}

else {

alert(“Please select a row to delete first”);

}

}

 

 

 

Radgrid total records after filtering

 

private int totalItemCount;

protected void rgList_ItemEvent(object sender, GridItemEventArgs e)

{

if (e.EventInfo is GridInitializePagerItem)

{

totalItemCount = (e.EventInfo as GridInitializePagerItem).PagingManager.DataSourceCount;

}

}

 

 

 

 

 

Radgrid export to excel Hide filter column

Issue 1: How to export RadGrid without the filter item (HTML Excel, ExportOnlyData=”false“)

When IgnorePaging is set to “false” you can use this approach:

protected void Button1_Click(object sender, EventArgs e)

{

foreach (GridFilteringItem item in RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem))

item.Visible = false;

RadGrid1.MasterTableView.ExportToExcel();

}
This will work with IgnorePaging=”true”:

bool isExport = false;

protected void Button1_Click(object sender, EventArgs e)

{

isExport = true;

RadGrid1.MasterTableView.ExportToExcel();

}

 

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)

{

if (isExport && e.Item is GridFilteringItem)

e.Item.Visible = false;

}

 

 

 

Scroll radpane to top

 

//scrolling radpane to top, so user can see loading panel

var splitter = $find(“<%= RadSplitter1.ClientID %>”);

var pane1 = splitter.getPaneById(“RadBottomPane”);

pane1.setScrollPos(0, 0);

 

 

 

 

 

 

 

 

Radgrid excel export Column header and row alignment formatting

 

bool isExport = false;

protected void rgList_ItemCreated(object sender, GridItemEventArgs e)

{

if (isExport && e.Item is GridFilteringItem)

e.Item.Visible = false;

if (isExport && e.Item is GridHeaderItem)

{

GridHeaderItem HeaderItem = (GridHeaderItem)e.Item;

 

//for column header – align left

foreach (TableCell cell in HeaderItem.Cells)

{

cell.Style[“text-align”] = “left”;

}

}

 

}

 

 

//for numeric cells – align left

protected void rgList_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)

{

GridDataItem item = e.Cell.Parent as GridDataItem;

if (e.FormattedColumn.UniqueName == “ColumnA” || e.FormattedColumn.UniqueName== “ColumnB”)

{

e.Cell.Style[“text-align”] = “left”;

}

}

 

Radgrid export to excel set Title/Caption

 

protected void RadCxtMenu_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)

{

if (e.Item.Text == “Export to Excel”)

{

isExport = true;

string title = string.Format(“<span><br/><b>Your title {0}</b></span>”, rcbControl.Text);

string reportDate = string.Format(“<span><br/>Report Generation Date : {0}</span>”, DateTime.Now.ToString(“dd-MMM-yyyy hh:mm tt”));

          rgList.MasterTableView.Caption = title + reportDate;

 

 

 

rgList.MasterTableView.ExportToExcel();

}

else if (e.Item.Text == “Export to Word”)

{

rgList.MasterTableView.ExportToWord();

}

 

 

RadGrid Initialize Insert Item

 

radgItems.MasterTableView.InsertItem();

GridEditableItem i = (GridEditableItem)radgItems.MasterTableView.GetInsertItem();

RadDatePicker r = (i.FindControl(“rdpDate”)) as RadDatePicker;

r.MinDate = DateTime.Now.Date.AddDays(1);

 

RadGrid Initialize Edit Item

 

 

selectedItem.FireCommandEvent(“Edit”, String.Empty);

// initialize

GridEditableItem selectedEditItem = (GridEditableItem)radgItems.EditItems[0];

RadDatePicker rdpDate = selectedEditItem.FindControl(“rdpDate”) as RadDatePicker;

rdpScheduledDate.MinDate = DateTime.Now.Date.AddDays(1);

 

 

 

 

 

 

 

 

SharePoint online OOTB Task list not sending email to assignee

Last week I was supporting a user that SharePoint online OOTB task list not receiving email, in fact task list not sending email to any assigned person.

Of course the first thing I check it Task List > Advance Settings > E-Mail Notification option, but ‘Send e-mail when ownership is assigned’ is selected as ‘Yes’. So this should send email, why it doesn’t send.  Continue reading SharePoint online OOTB Task list not sending email to assignee

How to upload folder to SharePoint Online list

Hello long time no blogging, yes I am back to share my daily programmer life.

Today I was trying to upload a folder to document library using the normal way, Sync or Open folder with window explorer. But only for this Site Collection’s document library, Sky Drive for Business showing error “Unable to parse SOAP response. … document must have a top level element.”  Continue reading How to upload folder to SharePoint Online list