<telerik:GridTemplateColumn HeaderText="Ortalama" DataField="Ortalama" UniqueName="Ortalama"
SortExpression="Ortalama" HeaderStyle-Width="80px" >
<ItemTemplate>
<%# String.Format("{0:f2}", DataBinder.Eval(Container.DataItem, "Ortalama"))%>
</ItemTemplate>
</telerik:GridTemplateColumn>
the solution is from: http://stackoverflow.com/questions/5168592/force-a-string-to-2-decimal-places
11 Ocak 2013 Cuma
RadGrid: format double with eval
In order to format double with eval :
RadComboBox: custom sorting of items
The link (http://www.telerik.com/help/aspnet-ajax/combobox-how-to-implement-custom-sorting.html) explains how to implement a custom sorting mechanism for RadComboBox..
It says that Telerik RadComboBox sorts by using the text by default, but it seems to use the value instead..
In order to sort by text, the following class can be used:
It says that Telerik RadComboBox sorts by using the text by default, but it seems to use the value instead..
In order to sort by text, the following class can be used:
1: public class RadComboSortByText : IComparer
2: {
3: public int Compare(object x, object y)
4: {
5: RadComboBoxItem p1 = new RadComboBoxItem();
6: RadComboBoxItem p2 = new RadComboBoxItem();
7: if (x is RadComboBoxItem)
8: p1 = x as RadComboBoxItem;
9: if (y is RadComboBoxItem)
10: p2 = y as RadComboBoxItem;
11: int cmp = 0;
12: if (p1.ComboBoxParent.Sort == RadComboBoxSort.Ascending)
13: {
14: //here we compare the Text of the items
15: cmp = String.Compare(p1.Text, p2.Text, !p1.ComboBoxParent.SortCaseSensitive);
16: }
17: if (p1.ComboBoxParent.Sort == RadComboBoxSort.Descending)
18: {
19: //here we compare the Text of the items
20: cmp = String.Compare(p1.Text, p2.Text, !p1.ComboBoxParent.SortCaseSensitive) * -1;
21: }
22: return cmp;
23: }
24: }
.. and itemBound of RadComboBox:
1: protected void ComboEgitimDali_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
2: {
3: ComboEgitimDali.Sort = RadComboBoxSort.Ascending;
4: ComboEgitimDali.SortItems(new RadComboSortByText());
5: }
<telerik:RadComboBox ID="ComboEgitimDali" runat="server" OnItemDataBound="ComboEgitimDali_ItemDataBound">
10 Ocak 2013 Perşembe
RadGrid: to deselect the last selected item on client side
In order to deselect the last selected item in the RadGrid, the following function can be used on client side:
javascript:
javascript:
<telerik:RadCodeBlock ID="RadCodeBlock" runat="server">
<script type="text/javascript">
function DeselectLastSelected(gridID, index) {
var masterTable = $find(gridID).get_masterTableView();
masterTable.deselectItem(masterTable.get_selectedItems()[index].get_element());
}
function RowSelected(sender, eventArgs) {
if (sender != null) {
var numOfSelected = sender.get_masterTableView().get_selectedItems().length;
DeselectLastSelected(sender.ClientID, numOfSelected - 1);
}
}
</script>
</telerik:RadCodeBlock>
RadGrid:
telerik:RadGrid AutoGenerateColumns="False" ID="GridOgrenciDersListe" AllowFilteringByColumn="false"
AllowPaging="False" AllowSorting="False" runat="server" ShowGroupPanel="false"
Width="560px" AllowMultiRowSelection="True" ShowFooter="false" Visible="false">
<PagerStyle Mode="NextPrevAndNumeric" />
<GroupingSettings CaseSensitive="false" />
<ClientSettings EnableRowHoverStyle="true">
<Selecting AllowRowSelect="True" UseClientSelectColumnOnly="true"></Selecting>
<ClientEvents OnRowSelected="RowSelected" OnRowDeselected="RowDeselected" />
</ClientSettings>
<MasterTableView TableLayout="Fixed" DataKeyNames="ID" Font-Size="XX-Small" ClientDataKeyNames="ID">
<Columns>
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">
</telerik:GridClientSelectColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
9 Ocak 2013 Çarşamba
RadGrid: to disable select-all checkbox in header
In order to disable (or make invisible) the select-all checkbox, the following javascript may be used:
the javascript code:
the javascript code:
<telerik:RadCodeBlock ID="RadCodeBlock" runat="server">
<script type="text/javascript">
function DisableAllSelectOption(sender, eventArgs) {
var prefix = sender.ClientID.substring(0, sender.ClientID.lastIndexOf("_"));
document.getElementById(prefix + '<%= "_GridOgrenciDersListe_ctl00_ctl02_ctl00_ClientSelectColumnSelectCheckBox"%>').style.visibility = 'hidden';
}
</script>
</telerik:RadCodeBlock>
radgrid:
<telerik:RadGrid AutoGenerateColumns="False" ID="GridOgrenciDersListe" AllowFilteringByColumn="false"
AllowPaging="False" AllowSorting="False" runat="server" ShowGroupPanel="false"
Width="560px" AllowMultiRowSelection="True" ShowFooter="false" Visible="false">
<PagerStyle Mode="NextPrevAndNumeric" />
<GroupingSettings CaseSensitive="false" />
<ClientSettings EnableRowHoverStyle="true">
<Selecting AllowRowSelect="True" UseClientSelectColumnOnly="true"></Selecting>
<ClientEvents OnRowSelected="RowSelectionChanged" OnRowDeselected="RowSelectionChanged"
OnDataBound="RowSelectionChanged" OnGridCreated="DisableAllSelectOption"/>
</ClientSettings>
<MasterTableView TableLayout="Fixed" DataKeyNames="ID" Font-Size="XX-Small" ClientDataKeyNames="ID">
<Columns>
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">
</telerik:GridClientSelectColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
8 Ocak 2013 Salı
RadGrid: coloring a line dynamically on client side
In a radgrid, changing forecolor of a row dynamically on client side is pretty easy. It can be achieved by using GridTemplateColumn:
<telerik:GridTemplateColumn HeaderText='Not' HeaderStyle-Width="50px">
<ItemTemplate>
<div style='color: <%# Eval("Renk")%>'>
<%# Eval("OgrenciNihaiNot")%>
</div>
</ItemTemplate>
</telerik:GridTemplateColumn>
using javascript with multiple user controls
When using the same user control multiple times in the same page, accessing the user controls with javascript may be problematic, since locating a specific user control (i mean to seperate the user controls from each other) is a bit tricky.
In my condition, i solved by using a prefix as follows:
In my condition, i solved by using a prefix as follows:
1: function RowSelectionChanged(sender, eventArgs) {
2: if (sender != null) {
3: // to access a component in this user control
4: var prefix = sender.ClientID.substring(0, sender.ClientID.lastIndexOf("_"));
5: var param1= document.getElementById( prefix + '<%= "_LabelParam1" %>').value;
6: // to access a component in the main page
7: var prefixMainPage = sender.ClientID.substring(0, sender.ClientID.lastIndexOf("MyUserControl"));
8: var param2= document.getElementById(prefixAnaSayfa + '<%= "HiddenParam"%>').value;
9: }
10: }
several possible resolutions proposed in: http://stackoverflow.com/questions/562152/multiple-user-controls-and-javascript, http://stackoverflow.com/questions/2533573/using-getelementbyid-inside-user-control
Kaydol:
Kayıtlar (Atom)