Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
161 views
Again, couldn't find anything via search so...

I have a grid that seems to be overriding the sort order that I'm specifying in the data source's SelectCommand.  The table I'm trying to display has three columns; ID, Name, and DisplayOrder.  ID is the primary key on the table and is a char(3) SQL data type.  I am trying to sort the grid by: "DisplayOrder, Name" but no matter what I try, the grid is sorted by ID.  I've tried using a stored procedure in the SelectCommand, setting the DataKeyNames to "DisplayOrder, ID", and various combinations of Grid and MasterTableView properties to no avail.

Seems simple enough, but I can't figure it out.  Can someone help?

Thanks,

Jay

Grid declaration:
<telerik:RadGrid ID="ListGrid" 
    Skin="Hay" 
    AllowAutomaticDeletes="True" 
    AllowAutomaticInserts="True" 
    AllowAutomaticUpdates="True" 
    AutoGenerateColumns="false" 
    DataSourceID="SQLDataSource" 
    OnItemDataBound="ListGrid_ItemDataBound" 
    OnItemInserted="ListGrid_ItemInserted" 
    OnItemUpdated="ListGrid_ItemUpdated" 
    OnItemDeleted="ListGrid_ItemDeleted" 
    runat="server">  
      
    <ValidationSettings EnableValidation="true" /> 
      
    <MasterTableView  
        DataSourceID="SQLDataSource" 
        DataKeyNames="DisplayOrder, ID" 
        CommandItemDisplay="Top" 
        CommandItemSettings-AddNewRecordImageUrl="~/_Images/GIF/16x16/Add.gif" 
        CommandItemSettings-AddNewRecordText="Add pet type" 
        CommandItemStyle-HorizontalAlign="Left" 
        EditMode="InPlace" 
        AutoGenerateColumns="false">  
          
        <SortExpressions> 
            <telerik:GridSortExpression FieldName="DisplayOrder" SortOrder="Ascending" /> 
            <telerik:GridSortExpression FieldName="Name" SortOrder="Ascending" /> 
        </SortExpressions> 
 
        <NoRecordsTemplate> 
            <div style="padding-top:10px;padding-bottom:10px;padding-left:20px;">  
                <asp:Label ID="NoItemsLabel" 
                    Text="There are no items to show in this view." 
                    runat="server" /> 
            </div> 
        </NoRecordsTemplate> 
          
        <Columns> 
            <telerik:GridTemplateColumn UniqueName="LeftSpacer" 
                HeaderStyle-Width="6" 
                ItemStyle-Width="6">  
                <HeaderTemplate> 
                    &nbsp;  
                </HeaderTemplate> 
            </telerik:GridTemplateColumn> 
              
            <telerik:GridBoundColumn UniqueName="ID" 
                HeaderText="ID" 
                HeaderStyle-Width="50" 
                ItemStyle-VerticalAlign="Top" 
                ItemStyle-Width="50" 
                DataField="ID" /> 
              
            <telerik:GridBoundColumn UniqueName="Name" 
                HeaderText="Name" 
                HeaderStyle-Width="150" 
                ItemStyle-VerticalAlign="Top" 
                ItemStyle-Width="150" 
                DataField="Name" /> 
              
            <telerik:GridBoundColumn UniqueName="DisplayOrder" 
                HeaderText="Display Order" 
                HeaderStyle-Width="100" 
                ItemStyle-VerticalAlign="Top" 
                ItemStyle-Width="100" 
                DataField="DisplayOrder" /> 
 
            <telerik:GridEditCommandColumn UniqueName="Edit" 
                ButtonType="ImageButton" 
                EditImageUrl="~/_Images/GIF/16x16/Edit.gif" 
                ItemStyle-Width="50" /> 
                  
            <telerik:GridButtonColumn UniqueName="Delete"   
                ButtonType="ImageButton" 
                CommandName="Delete" 
                Text="Delete" 
                ConfirmText="Delete this pet type?" 
                ConfirmTitle="Delete Pet Type" 
                ImageUrl="~/_Images/GIF/16x16/Delete.gif" /> 
                  
            <telerik:GridTemplateColumn UniqueName="RightSpacer" 
                HeaderStyle-Width="6" 
                ItemStyle-Width="6">  
                <HeaderTemplate> 
                    &nbsp;  
                </HeaderTemplate> 
            </telerik:GridTemplateColumn> 
        </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 
 

DataSource declaration:
<asp:SqlDataSource ID="SQLDataSource" 
    ConnectionString="<%$ ConnectionStrings:MainConnectionString %>" 
    ProviderName="System.Data.SqlClient" 
    InsertCommand="INSERT INTO [dbo].[PetType] (ID, Name, DisplayOrder) VALUES (UPPER(@ID), @Name, @DisplayOrder)" 
    SelectCommand="SELECT [ID], [Name], [DisplayOrder] FROM [dbo].[PetType] ORDER BY [DisplayOrder], [Name]" 
    UpdateCommand="UPDATE [dbo].[PetType] SET [ID] = UPPER(@ID), [Name] = @Name, [DisplayOrder] = @DisplayOrder WHERE [ID] = @original_ID" 
    DeleteCommand="DELETE FROM [dbo].[PetType] WHERE [ID] = @original_ID" 
    OldValuesParameterFormatString="original_{0}" 
    ConflictDetection="CompareAllValues" 
    runat="server">  
      
    <InsertParameters> 
        <asp:Parameter Name="ID" Type="String" /> 
        <asp:Parameter Name="Name" Type="String" /> 
        <asp:Parameter Name="DisplayOrder" Type="Int32" /> 
    </InsertParameters> 
      
    <UpdateParameters> 
        <asp:Parameter Name="ID" Type="String" /> 
        <asp:Parameter Name="Name" Type="String" /> 
        <asp:Parameter Name="DisplayOrder" Type="Int32" /> 
        <asp:Parameter Name="original_ID" Type="String" /> 
    </UpdateParameters> 
      
    <DeleteParameters> 
        <asp:Parameter Name="original_ID" Type="String" /> 
    </DeleteParameters> 
</asp:SqlDataSource> 
 
Jay Legere
Top achievements
Rank 1
 answered on 05 Aug 2009
3 answers
270 views
Hi, I have seen examples for totaling a column and having it display in the footer, but I would also like to be able to add an extra column to the grid that displays a total for the row. Is this possible?

I have 2 different scenarios. The first scenario is that I will autogenerate the columns for the grid and I would like to be able to add an extra column to the grid for which I will total the row across (maybe skipping the first or second column). In the second scenario I would build a dynamic grid and would add the extra column myself.

I am binding the grid to data coming from sql server but I can't add the extra computation on the sql server side.

Are there any examples for this and can it be done? Thanks in advance.



kachy
Top achievements
Rank 1
 answered on 04 Aug 2009
1 answer
183 views
I am tyring to create a report with autogenerated Radgrid and adding a Calculatedcolumn for row total. If the columns are declared in design mode and I use EnableLinqExpressions false, filter for DateTime and the calculated column works but for autogenerated columns - I get following error for DateTime filter and Calculated Column filter.

For DateTime filter:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

For GridCalculated Column the error is:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Expression of type 'System.Nullable`1[System.Int32]' cannot be used for parameter of type 'System.Object' of method 'System.String ToString(System.Object)'


Can you please suggest what can I do to fix that error.

Thanks.
kachy
Top achievements
Rank 1
 answered on 04 Aug 2009
2 answers
89 views
Hello,

I had my RadGrid with DataSourceID - from Database. The data displays fine.
 My original goal is delete the recod on the server and I noticed the sample from Help.

<telerik:RadGrid id="RadGrid1" runat="server" OnDeleteCommand="RadGrid1_DeleteCommand"
OnNeedDataSource="RadGrid1_NeedDataSource">
<MasterTableView AutoGenerateColumns="False" DataKeyNames="CustomerID">
   
<Columns>
  ........
When I tried to use that, the application never fires OnNeedDataSource event, 
so my Grid is always empty .

Did I missed something or this code sample is not complete.

Please help
Coty
Top achievements
Rank 1
 answered on 04 Aug 2009
3 answers
485 views
Hi,

I have a RadTreeView control inside the RadCombobox's  <Item Template>
Now I need to databind the RadTreeView from the code behind. How can I access the this control from the code behind?

Any help will be greatly appreciated.

<telerik:RadComboBox ID="RadComboBoxCategoryLevels"
                         Width="160px"
                         Height="300px"
                         AllowCustomText="false"
                         runat="server" >
                        <ItemTemplate >
                            <div onclick="StopPropagation(event)">
                                <telerik:RadTreeView ID="RadTreeView"
                                                     runat="server"
                                                     OnClientNodeClicking="OnclientNodeClickingHandler">
                                                     <DataBindings >
                                                        <telerik:RadTreeNodeBinding Depth="0" Expanded="true" />
                                                     </DataBindings>                                                     
                                </telerik:RadTreeView>
                            </div>                            
                        </ItemTemplate>                     
    </telerik:RadComboBox>
venm
Top achievements
Rank 1
 answered on 04 Aug 2009
1 answer
231 views
Hello,
I need to use tree view to dsipaly the category structure in my web applicaion. I want the user to change the order of categories in the same level.
Example:
                        Accessories
                        ....Business Gifts
                        Apparel
                        ....Hats
                        ....shirts
                        ....Jackets


This is my category structure. If i try with telerik treeview it allows me to drag the Hats category and place it under accessories. but  my requiremnet is i should be able to change only the position of hats, shirts and Jackets(categories of same level in a catategory) and should not allow to change the category structure across different categories.
can any one help on this

Regards,
Parvati


Mr. Plinko
Top achievements
Rank 1
 answered on 04 Aug 2009
2 answers
298 views
Hi,
I am using radgrid which has two colum with radnumerictextbox . When i click the add new record i use the code block to find the radnumerictextbox after the finding i  add OnKeyPress Attributes to boxes .

     if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
            {  
                if (e.Item.OwnerTableView.IsItemInserted)  
                {  
                    //item is about to be inserted  
                    GridEditableItem dataItem = (GridEditableItem)e.Item;  
                    RadNumericTextBox rntBorc = (RadNumericTextBox)dataItem.FindControl("tbBorc");  
                    RadNumericTextBox rntAlacak = (RadNumericTextBox)dataItem.FindControl("tbAlacak");  
                    rntBorc.Value = 0.00;  
                    rntAlacak.Value = 0.00;  
 
                    if (rntBorc != null)  
                    {  
                        rntBorc.Attributes.Add("onKeyPress", "return onKeyPressBorcInsert('" + rntBorc.ClientID + "', '" + rntAlacak.ClientID + "');");    
                    }    
                      
                    if (rntAlacak != null)  
                    {  
                        rntAlacak.Attributes.Add("OnKeyPress", "return onKeyPressAlacakInsert('" + rntBorc.ClientID + "', '" + rntAlacak.ClientID + "');");  
                    }  
                }  

function onKeyPressBorcInsert(rntBorcClientID, rntAlacakClientID)   
{       
 
}  
 
function onKeyPressAlacakInsert(rntBorcClientID, rntAlacakClientID)   
{       
 
}  
      

The Code Block above  working good .

But i want to add OnKeyPress attributes like this

rntBorc.Attributes.Add("onKeyPress", "return onKeyPressBorcInsert('" + rntBorc.ClientID + "', '" + rntAlacak.ClientID + "',event);");

function onKeyPressBorcInsert(rntBorcClientID, rntAlacakClientID,eventArgs)   
{       
var x =  eventArgs.get_inputText();
}
because i want to get character user enter ..

but the code is not working  . How can i do this ??

can take OnKeyyPress function 3 arguments or more ??






fatih ak
Top achievements
Rank 1
 answered on 04 Aug 2009
2 answers
254 views
I have been trying to use the new GridBinaryImageColumn to display data in an Oracle table. After a few days of trying different things, I finally have it doing the inserts. I pretty much have to do the inserts manually as no matter how I tried I couldn't get the declaritve methods to work. My problem now is displaying the image in the grid column, the data is in the table, but the grid just displays it as a broken image, I guess it doesn't like the way Oracle returns the binary data (I have it stored in a BLOB column). I guess I need to know what I need to do, to get it to display the image correctly.

Here is the relevant part of the .aspx page:
<asp:ObjectDataSource ID="IssueScreenshotsDataSource" runat="server" TypeName="IssuesDataAccess" 
        DeleteMethod="DeleteIssueScreenshot" OldValuesParameterFormatString="original_{0}" 
        SelectMethod="GetIssueScreenshotsByIssueID">  
        <DeleteParameters> 
            <asp:Parameter Name="imageID" Type="Int32" /> 
        </DeleteParameters> 
        <SelectParameters> 
            <asp:Parameter Name="issueID" Type="Int32" /> 
        </SelectParameters> 
    </asp:ObjectDataSource> 

<
telerik:GridTableView DataKeyNames="imageID" DataSourceID="IssueScreenshotsDataSource" Width="100%" 
                    runat="server" CommandItemDisplay="Top" Name="Screenshots">  
                    <ParentTableRelation> 
                        <telerik:GridRelationFields DetailKeyField="issueID" MasterKeyField="issueId" /> 
                    </ParentTableRelation> 
                    <CommandItemSettings AddNewRecordText="Add A Screenshot" /> 
                    <Columns> 
                        <telerik:GridTemplateColumn HeaderText="Image Name" UniqueName="filename">  
                            <ItemTemplate> 
                                <asp:Label runat="server" ID="lblName" Text='<%# Eval("fileName") %>' /> 
                            </ItemTemplate> 
                            <EditItemTemplate> 
                                <telerik:RadTextBox runat="server" Width="200px" ID="txbName" Text='<%# Bind("fileName") %>' /> 
                                <asp:RequiredFieldValidator ID="Requiredfieldvalidator1" runat="server" ControlToValidate="txbName" 
                                    ErrorMessage="Please, enter a name!" Display="Dynamic" SetFocusOnError="true" /> 
                            </EditItemTemplate> 
                            <HeaderStyle Width="30%" /> 
                        </telerik:GridTemplateColumn> 
                        <telerik:GridBinaryImageColumn DataField="data" HeaderText="Screenshot" UniqueName="screenshot" 
                            ImageAlign="NotSet" ImageHeight="60px" ImageWidth="60px" ResizeMode="Fit">  
                        </telerik:GridBinaryImageColumn> 
                        <telerik:GridButtonColumn ConfirmText="Are you sure you wish to delete this Screenshot?" 
                            ButtonType="imageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn1">  
                            <ItemStyle HorizontalAlign="Center" /> 
                        </telerik:GridButtonColumn> 
                    </Columns> 
                </telerik:GridTableView> 
The select method returns a DataSet from an Oracle procedure:
PROCEDURE APPS_ISSUE_GET_SCRNSHOT_BY_FK (  
   p_issue_id   IN       NUMBER,  
   cur_out      OUT      sys_refcursor  
)  
IS 
BEGIN 
   OPEN cur_out FOR 
      SELECT image_id imageID, issue_id issueID, file_data data,  
             file_name fileName  
        FROM apps_issue_screenshots  
       WHERE (issue_id = p_issue_id);  
END
Kyle Koss
Top achievements
Rank 1
 answered on 04 Aug 2009
3 answers
400 views
Hi
I am using telerik grid and data is bound programatically to the grid.
When i allow grouping in the client side and drag and drop columns to group it throws the error shown beolw (even after setting the groupby expressions for the columns).Please find the code to populate grid and the apsx content at the end of the mail.

Expression cannot be null or empty

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Telerik.Web.UI.GridGroupByException: Expression cannot be null or empty

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[GridGroupByException: Expression cannot be null or empty]
   Telerik.Web.UI.GridGroupByExpression.SetExpression(String expression) +99
   Telerik.Web.UI.GridGroupByExpression.set_Expression(String value) +29
   Telerik.Web.UI.GridGroupByExpression..ctor(GridColumn column) +305
   Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) +6231
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433


ASPX Content of grid:

 

<telerik:RadGrid ID="RadGrid1" runat="server"

 

 

    AllowCustomPaging="True"

 

 

    AutoGenerateColumns="False"

 

 

    AllowPaging="True"

 

 

    AllowFilteringByColumn="True"

 

 

    AllowSorting="True"

 

 

    GridLines="None"

 

 

    ShowGroupPanel="True" 
    GroupingEnabled="True"

 

 

    ongridexporting="RadGrid1_GridExporting1"

 

 

    onpdfexporting="RadGrid1_PdfExporting"

 

 

    onpageindexchanged="RadGrid1_PageIndexChanged1"

 

 

    ongroupschanging="RadGrid1_GroupsChanging" onneeddatasource="RadGrid1_NeedDataSource">

 

<

 

MasterTableView>

 

<

 

RowIndicatorColumn>

 

<

 

HeaderStyle Width="20px"></HeaderStyle>

 

</

 

RowIndicatorColumn>

 

</

 

MasterTableView>

 

<

 

ClientSettings AllowDragToGroup="true">
</
ClientSettings>

 

<

 

PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" />

 

<

 

FilterMenu EnableTheming="True">

 

<

 

CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

</

 

FilterMenu>

 

 

</telerik:RadGrid>

Code:

public

 

void PopulateGrid()

 

{

 

DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM abc", "server=10.100.111.11;database=abcd;Uid=aa;pwd=aa;");

 

adapter.Fill(ds);


foreach
(DataColumn col in ds.Tables[0].Columns)

 

{

 

    GridBoundColumn gridboundcolumn = new GridBoundColumn();

 

    gridboundcolumn.DataField = col.ColumnName;

    gridboundcolumn.HeaderText = col.ColumnName

;

 

    gridboundcolumn.UniqueName = col.ColumnName;

    gridboundcolumn.SortExpression = col.ColumnName;

    gridboundcolumn.Display =

true;

 

    gridboundcolumn.Groupable =

true;

 

    gridboundcolumn.GroupByExpression = gridboundcolumn.GetDefaultGroupByExpression();

    RadGrid1.Columns.Add(gridboundcolumn);

}

RadGrid1.VirtualItemCount = 2000;

 

RadGrid1.DataBind();

 

}

Arnold Smith
Top achievements
Rank 1
 answered on 04 Aug 2009
4 answers
215 views
I tried to find out any available event in server or client sides which will be fired in out-of-band (AJAX) when user modifies any cell value and move out the cell. So the new value can be validated in server side and also it could change the value on other cell or change the dropdown list on other column according to the new value.
Virendra
Top achievements
Rank 1
 answered on 04 Aug 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?