Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
284 views
I am trying use the sorting properties in the radgrid, and I am wondering if there is a way to sort the data bound to the grid without hitting the database again.  My problem is when I do not hit the database and attempt to sort, my data in the grid disappears.

My radgrid is set up to look like this:
<radG:RadGrid ID="CustomerGrid" runat="server" AutoGenerateColumns="false" Width="100%" EnableAJAX="True" OnPageIndexChanged="SearchResults_PageIndexChanged" 
    Skin="Office2007" AllowFilteringByColumn="False" AllowPaging="True" PageSize="35" ShowStatusBar="True" ShowFooter="False" 
    ShowGroupPanel="False" GridLines="None" CellPadding="1" AllowSorting="True" OnSortCommand="RadGrid1_SortCommand">
    <PagerStyle Mode="NextPrevAndNumeric" />
    <MasterTableView EditMode="InPlace" ShowFooter="True" Width="99%" TableLayout="Auto" AllowMultiColumnSorting="true" AllowNaturalSort="true">
        <Columns>
            <radG:GridBoundColumn DataField="CustomerID" HeaderText="Customer Number" SortExpression="CustomerID" UniqueName="CustomerID">
            </radG:GridBoundColumn>
            <radG:GridBoundColumn DataField="CustomerName" HeaderText="Customer Name" SortExpression="CustomerName" UniqueName="CustomerName">
            </radG:GridBoundColumn>
            <radG:GridTemplateColumn HeaderText="Status" HeaderStyle-Width="160px" ItemStyle-Width="160px">
                <ItemTemplate>
                    <%# GetStatus(Eval("CustomerID")) %>
                </ItemTemplate>
            </radG:GridTemplateColumn>
            <radG:GridBoundColumn DataField="Effective" HeaderText="Effective">
            </radG:GridBoundColumn>
        </Columns>
        <ExpandCollapseColumn Visible="False">
            <HeaderStyle Width="19px" />
        </ExpandCollapseColumn>
        <RowIndicatorColumn Visible="False">
            <HeaderStyle Width="20px" />
        </RowIndicatorColumn>
    </MasterTableView>
    <ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True">
        <Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>
    </ClientSettings>
</radG:RadGrid>

My code behind methods for sorting and loading the radgrid are shown below:
protected void SearchResults_PageIndexChanged(object source, Telerik.WebControls.GridPageChangedEventArgs e)
{
    LoadData();
}
  
protected void RadGrid1_SortCommand(object source, Telerik.WebControls.GridSortCommandEventArgs e)
{
    if (!e.Item.OwnerTableView.SortExpressions.ContainsExpression(e.SortExpression))
    {
        GridSortExpression sortExpr = new GridSortExpression();
        sortExpr.FieldName = e.SortExpression;
        sortExpr.SortOrder = GridSortOrder.Ascending;
  
        e.Item.OwnerTableView.SortExpressions.AddSortExpression(sortExpr);
    }
  
}

The LoadData method is used to get the results from the database and returns a data set which I bind to the radgrid.

The Sort method I tried using from the demo, I found here:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/sorting/defaultcs.aspx


From this I would like to be able to sort all of my columns, except for the effective column, in ascending or descending order depending on what the user selects.  I was also curious if you could offer up any assitance as to how to go about sorting my Item Template column, if that is possible.  Since, my CustomerID is bound to the column and I just use code to display the customer's status, I was not sure if this was possible to sort by the actual status name.

Any assistance would be appreciated. Thanks.

Joe
Iana Tsolova
Telerik team
 answered on 06 Jun 2011
2 answers
80 views
Hello, I have a radgrid that is being populated with a mysql odbc datasource. I am trying to get the update command to update information from my edited item to the database. as of right now, if you click edit, the item goes into edit mode. if you add text then click update, it postsback, but no data is loaded to the database. I need this to work as an itemCommand "Update" in a select case as I need to dynamically populate data to be added through another function. I have tried using just a standard "OnUpdate" but that also is not working. here is the offending code, HELP PLEASE 




*****Previous Code*****

  Protected Sub gridfflistings_UpdateCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs)
        Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
        Dim rowid As String = gridfflistings.MasterTableView.DataKeyValues(e.Item.ItemIndex)("propertyid")
        Dim Dlink As String = editedItem("txtlink").Text
        Dim add1 As String = editedItem("address").Text
        Dim propid As String = rowid.ToString
        Dim upstr As String = "update fflistings set mlsnumber=?, directlink=? where propertyid=?;"
        Dim upcon As New OdbcConnection(sConnectionString)
        upcon.Open()
        Using upcom As New OdbcCommand(upstr, upcon)
            upcom.Parameters.AddWithValue("mlsnumber", "11111")
            upcom.Parameters.AddWithValue("directlink", Dlink.ToString)
            upcom.Parameters.AddWithValue("propid", rowid.ToString)
            Try
                upcom.ExecuteNonQuery()
                gridfflistings.Rebind()
                lbldebug.Text = " updated information"
                upcon.Close()
            Catch ex As Exception
                lbldebug.Text = "There was an issue updating the db" & ex.Message
            End Try
        End Using
    End Sub



******the grid*****

<telerik:radgrid id="gridfflistings" datasourceid="sqlfflistings" runat="server" width="800px" OnUpdateCommand="gridfflistings_UpdateCommand" AllowAutomaticUpdates="false">                
                <MasterTableView DataSourceID="sqlfflistings" DataKeyNames="propertyid" AutoGenerateColumns="false" EditMode="EditForms" >
                <columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" >               
                </telerik:GridEditCommandColumn>               
                <telerik:GridBoundColumn HeaderText="Property ID" datafield="propertyid" readonly="true" visible="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Address" datafield="address1" uniquename="address" readonly="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="City" datafield="city" readonly="true"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn HeaderText="State" DataField="state" readonly="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Zip Code" DataField="Zipcode" readonly="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="M6P ID" DataField="m6plistingid" readonly="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="MLS" DataField="mlsnumber" ReadOnly="true" ></telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Direct Link" DataField="directlink" UniqueName="directlink" ColumnEditorID="newlink" Visible="false" ReadOnly="true"></telerik:GridBoundColumn>
                <telerik:GridTemplateColumn UniqueName="newlink" headertext="Direct Link">
                    <ItemTemplate>
                        <asp:Label ID="lbllink" runat="server"></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtlink" runat="server"></asp:TextBox>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridCheckBoxColumn HeaderText="Paid" DataField="pstatus" readonly="true"></telerik:GridCheckBoxColumn>
                </columns>
                </MasterTableView>
                </telerik:radgrid>

I have changed the code as follows to try and use a custom edit form to see if that would fix the issue. I have done some testing and it is updating data to the db, it is just NOT capturing the data from the edit form. It keeps applying a &nbsp; to the db instead of the values needed. I have altered the code above to the new code, PLEASE HELP! I have to get this function finished TODAY!!!!!!  now when I click the update button it does not leave edit mode. 
Iana Tsolova
Telerik team
 answered on 06 Jun 2011
1 answer
106 views
i have a radtextbox

 <telerik:RadTextBox ID="rtbItemDescription" runat="server" TabIndex="1050"
                                            MaxLength="<%$ Resources:ItemResources,rtbItemDescriptionMaxLength %>"
                                            Width="<%$ Resources:ItemResources,rtbItemDescriptionWidth %>"  
                                            TextMode="MultiLine" Rows="<%$ Resources:ItemResources,rtbItemDescriptionRows %>"                                        
                                             ontextchanged="rtbItemDescription_TextChanged" >
                                        </telerik:RadTextBox>


from resource  file rtbItemDescriptionMaxLength ="160"
                             rtbItemDescriptionWidth ="150"
                            rtbItemDescriptionRows="3"
when i save data by clicking radbutton
control goes to this line in javascript file
b._textBoxElement.select(); error occurs "microsoft javascript error invalid function"
Martin
Telerik team
 answered on 06 Jun 2011
2 answers
87 views
hy everyone , i'm still a noob at telerik controls , i have a project and i want to use the RadScheduler , i used it with a database witch got a table named event(id,text,de(start),a(end)), it works , i mean it shows the events , but just shows , i cant delete , drag or create , and i really dont have an idea how to do , plz if u can help me :S
Plamen
Telerik team
 answered on 06 Jun 2011
3 answers
384 views

How i find in radcombobox in javascript tag ,

<telerik:RadCodeBlock runat="server" ID="radCodeBlock">
        <script type="text/javascript">
            function onSelectedIndexChanged(sender, eventArgs) {
                debugger;
                updateComboBox(sender);
            }

            function updateComboBox(listBox) {
                var text = "";
                var value = "";
                var items = listBox.get_selectedItems();

                for (var i = 0; i < items.length; i++) {
                    var item = items[i];

                    //Check whether the Item's 'selected' attribute is set to true.
                    if (item.get_selected()) {
                        text += item.get_text() + ", ";
                        value += item.get_value() + ", ";
                    }
                }

                text = text.substring(0, text.length - 2);
                value = value.substring(0, value.length - 2);

                var comboBox = $find("ComboBox_SortColumn");

                //Set the text of the RadComboBox to the texts of the selected Items, separated by ','.
                comboBox.set_text(text);

                //Set the value of the RadComboBox to values of the selected Items, separated by ','.
                comboBox.trackChanges();
                comboBox.get_items().getItem(0).set_value(value);
                comboBox.commitChanges();
            }

        </script>
    </telerik:RadCodeBlock>



<EditFormSettings CaptionFormatString="Create" EditFormType="Template">

  <td>
                                                                        <asp:Label ID="Label15" runat="server">Selected</asp:Label>
                                                                        <telerik:RadListBox runat="server" DataTextField="Text" DataValueField="Value" ID="RadListBoxDestinationGroup"
                                                                            AutoPostBackOnReorder="true" EnableDragAndDrop="true" AllowReorder="true" Height="140px"
                                                                            Width="160px" ButtonSettings-Position="Left" OnClientSelectedIndexChanged="onSelectedIndexChanged">
                                                                        </telerik:RadListBox>
                                                                    </td>

<td>
                                                        <telerik:RadComboBox ID="ComboBox_SortColumn" runat="server" Width="175px" SelectedValue='<%# Bind("SortColumn") %>'
                                                            AllowCustomText="true">
                                                            <Items>
                                                                <telerik:RadComboBoxItem Text="" />
                                                            </Items>
                                                        </telerik:RadComboBox>
                                                    </td>
<EditFormSettings/>



Thanks,
Mohamed.
Iana Tsolova
Telerik team
 answered on 06 Jun 2011
1 answer
121 views
Is it possible to output the following to a RadGrid rather than just the page?

Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
    Dim newPaswordSecureString As System.Security.SecureString = New System.Security.SecureString()
    Dim newPassword As String = "password"
    For Each c As Char In newPassword
        newPaswordSecureString.AppendChar(c)
    Next
    Dim credential As PSCredential
    credential = New PSCredential("userame", newPaswordSecureString)
    'Set the connection Info
    Dim connectionInfo As WSManConnectionInfo = New WSManConnectionInfo(New Uri("http://tusdcas1.tusd.local/powershell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential)
    Dim runspace As Runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo)
    runspace.Open()
    Dim newMbx As Command
    newMbx = New Command("Get-MailboxStatistics")
    newMbx.Parameters.Add("Server", "TUSDMBSTORAGE1.tusd.local")
    Dim cmd As Pipeline = runspace.CreatePipeline()
    cmd.Commands.Add(newMbx)
    Dim commandResults As Collection(Of PSObject)
    commandResults = cmd.Invoke()
    For Each cmdlet As PSObject In commandResults
        Dim _cmdletDisplayName As String = cmdlet.Properties("DisplayName").Value.ToString()
        Dim _cmdletTotalItemSize As String = cmdlet.Properties("TotalItemSize").Value.ToString()
        Dim _cmdletLegacydn As String = cmdlet.Properties("LegacyDN").Value.ToString()
        Response.Write("Mailbox No.:" + _cmdletDisplayName + "," + _cmdletTotalItemSize + "," + _cmdletLegacydn)
    Next
End Sub

Thank you.
Hus Damen
Top achievements
Rank 1
 answered on 06 Jun 2011
1 answer
32 views
Is there a way to retain sort of grid across post backs & page redirections?

Thank you

Regards
Raj
Shinu
Top achievements
Rank 2
 answered on 06 Jun 2011
3 answers
135 views
Hi, 

    When i select a filter in the RadGrid send me an error here:

        Telerik.Web.UI.GridTableView.registerClass(

"Telerik.Web.UI.GridTableView",Sys.UI.Control);

 

        Telerik.Web.UI.GridFilterFunction=

function(){};

 

        Telerik.Web.UI.GridFilterFunction.prototype= {NoFilter:0,Contains:1,DoesNotContain:2,StartsWith:3,EndsWith:4,EqualTo:5,NotEqualTo:6,GreaterThan:7,LessThan:8,GreaterThanOrEqualTo:9,LessThanOrEqualTo:10,Between:11,NotBetween:12,IsEmpty:13,NotIsEmpty:14,IsNull:15,NotIsNull:16,Custom:17};

        Telerik.Web.UI.GridFilterFunction.registerEnum(

"Telerik.Web.UI.GridFilterFunction",false);

 

        Telerik.Web.UI.GridFilterFunction.parse=

function(b,a){return(typeof b=="number")?b:Sys$Enum$parse.call(this,b,!!a);

    Sys$Enum$parse is not defined

thank you for your help.

 

Iana Tsolova
Telerik team
 answered on 06 Jun 2011
1 answer
42 views
We are currently using an older version of RadGrid (4.0.1.0) in our application and I have noticed that the javascript being used access the MasterTableView is no longer working in FF4.0.1. It was working fine in FF3.5

The script in question looks the same as your samples:
function ShowEditForm(id, rowIndex) {
    var grid = window["<%= grd.ClientID %>"];
    var rowControl = grid.MasterTableView.Rows[rowIndex].Control;               
    grid.MasterTableView.SelectRow(rowControl, true);
    return ShowPopup("<%= GetUrl() %>" + id);
}

The same code works fine in IE8. In FF4, Firebug reports the variable 'grid' as Object { } and grid.MasterTableView is undefined. Under FF3.5, the variable 'grid' is listed as Object { Type="RadGrid" }

Any ideas how to fix this without upgrading the Rad controls?

Regards
Alan
Hus Damen
Top achievements
Rank 1
 answered on 06 Jun 2011
1 answer
160 views
I have a grid bound to a dynamic view. I am using the NeedDataSource and have the AutoGenerateColumns set to true because I never know what the column headers or count will be.

I have AllowFiltering set to true to allow users to work with the returned data. There are a couple of column settings I would like to apply to all columns and I am hoping to avoid writing a bunch of code in the PreRender event and then rebinding.

I would like to set the default filter (CurrentFilterFunction) to "StartsWith" and not "Contains" for all columns.
I would like to set the default FilterControlWidth to be the same width for all columns. I noticed that string columns are one size and numeric columns are another (larger?).

I've serched through the forums but can't find anything. If someone can provide a link or a suggestion that would be great.
 
Thanks,
Craig
Princy
Top achievements
Rank 2
 answered on 06 Jun 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?