Telerik Forums
UI for ASP.NET AJAX Forum
7 answers
191 views
   
I have a grid that is working fine, the problem is, when I put it inside RadAjaxPanel, I click 
add new record, the insert open successfully, I enter the values and click insert the RadGrid_InsertCommand
does not get invoked, and the grid shows empty again...

When I remove it from RadAjaxPanel it works normally..

Any pointers to this behavior ??
 


<
telerik:radgrid ID="radgrid_Languages"  runat="server" Skin="Office2007"
            GridLines="None" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
            Width="97%" OnNeedDataSource="RadGrid_NeedDataSource"
            OnDeleteCommand="RadGrid_DeleteCommand"
            OnInsertCommand="RadGrid_InsertCommand"
            OnUpdateCommand="RadGrid_UpdateCommand" EnableAJAX="True" 
            <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle
                
            <MasterTableView DataKeyNames="ID" GridLines="None" Width="100%" CommandItemDisplay ="Top"
                
<CommandItemSettings ExportToPdfText="Export to Pdf" AddNewRecordText="Add new language"></CommandItemSettings>
                
                <Columns
                    <telerik:GridEditCommandColumn
                    </telerik:GridEditCommandColumn
                    <telerik:GridDropDownColumn DataField="LanguageID" DataSourceID="lds_Languages"
                        HeaderText="Language" ListTextField="LanguageName" ListValueField="ID"
                        UniqueName="LanguageID">
                    </telerik:GridDropDownColumn>
 
                   <telerik:GridDropDownColumn DataField="ReadLevelID" DataSourceID="lds_ProficiencyLevels"
                        HeaderText="Read" ListTextField="LevelName" ListValueField="ID"
                        UniqueName="ReadLevelID">
                    </telerik:GridDropDownColumn>
 
                    <telerik:GridDropDownColumn DataField="WriteLevelID" DataSourceID="lds_ProficiencyLevels"
                        HeaderText="Written" ListTextField="LevelName" ListValueField="ID"
                        UniqueName="WriteLevelID">
                    </telerik:GridDropDownColumn>
 
                    <telerik:GridDropDownColumn DataField="SpeakLevelID" DataSourceID="lds_ProficiencyLevels"
                        HeaderText="Spoken" ListTextField="LevelName" ListValueField="ID"
                        UniqueName="SpeakLevelID">
                    </telerik:GridDropDownColumn>
 
                    
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete"
                        UniqueName="Delete" ConfirmText="Are you sure you want to delete ?"
                        ConfirmTitle="Alert">  
                    </telerik:GridButtonColumn
                </Columns
                      <EditFormSettings>
                            <EditColumn UniqueName="EditCommandColumn1">
                            </EditColumn>
 
                            <FormStyle BackColor="#EEF2EA" Width="100%"></FormStyle>
 
                            <FormTableStyle CellPadding="2" CellSpacing="0"></FormTableStyle>
 
                            <FormTableItemStyle Height="29px" Width="100%"></FormTableItemStyle>
                        </EditFormSettings>
 
                <ExpandCollapseColumn Visible="False">  
                    <HeaderStyle Width="19px"></HeaderStyle
                </ExpandCollapseColumn
 
                   <NoRecordsTemplate>
                            <table style="width: 100%;height:100px">
                                <tr>
                                    <td>
                                        Please add your languages proficiency<br />
                                        <br />
                                        (Indicate Very Good , Good , Average , Weak )
                                    </td>
                                </tr>
                            </table>
                        </NoRecordsTemplate>
 
                <RowIndicatorColumn Visible="False">  
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn
            </MasterTableView
        </telerik:radgrid>
Rabeeh
Top achievements
Rank 2
 answered on 28 Sep 2010
1 answer
158 views
Hi
How do I add Items of RadcomboBox to a session.

I have a lstCourseCode to give back Tutor Emails which I want to store for each coursecode.

I probably have to use session array?
I dont know the length of array for Items.It will be dynamic.
And each item (lstCourseCode.SelectedItem.Text) should be stored in Session array.
On the same page OnClick of Submit I restore each of the session value to send emails.

Any suggestions !!!!


Shinu
Top achievements
Rank 2
 answered on 28 Sep 2010
1 answer
114 views
Hi

I am trying to bind a collection of objects to a Hierarchy grid. The Parent rows are the Comment objects and the Children are the Activity objects. The Comment object contains a list of Activity objects.

the code I'm trying to get working is

<telerik:RadGrid CssClass="telerikrid" ID="CommentsGrid1" runat="server" GridLines="None"
           Width="100%" ShowGroupPanel="False" AllowSorting="True" Skin="Windows7" OnNeedDataSource="Comments1_NeedDataSource"
           Font-Size="7">
           <MasterTableView RetrieveAllDataFields="true" AutoGenerateColumns="False">
               <DetailTables>
                   <telerik:GridTableView>
                    <ParentTableRelation>
                           <telerik:GridRelationFields DetailKeyField="JdeSite" MasterKeyField="JdeSite" />
                       </ParentTableRelation>
                       <Columns>
                              <telerik:GridBoundColumn DataField="JdeSite" HeaderText="Site" />
                           <telerik:GridBoundColumn DataField="Type" HeaderText="Type" />
                           <telerik:GridBoundColumn DataField="OwnerName" HeaderText="Owner" />
                       </Columns>
                   </telerik:GridTableView>
               </DetailTables>
               <Columns>
                   <telerik:GridBoundColumn DataField="JdeSite" HeaderText="Site" />
                   <telerik:GridBoundColumn DataField="JdeCode" HeaderText="JDE Site" />
                   <telerik:GridBoundColumn DataField="TradingName" HeaderText="Trading Name" />
                   <telerik:GridBoundColumn DataField="BookingStartDate" HeaderText="Booking Start Date" />
                   <telerik:GridBoundColumn DataField="BookingEndDate" HeaderText="Booking End Date" />
                   <telerik:GridBoundColumn DataField="Comments" HeaderText="Comments" />
               </Columns>
           </MasterTableView>
       </telerik:RadGrid>



public class Comment
  {
      public string OptyRowId { get; set; }
      public int WeekNo { get; set; }
      public string JdeSite { get; set; }
      public string JdeCode { get; set; }
      public string TradingName { get; set; }
      public DateTime BookingStartDate { get; set; }
      public DateTime BookingEndDate { get; set; }
      public string Comments { get; set; }
      public List<Activity> ActivityList { get; set; }
 
  }
   
   
   public class Activity
  {
      public string JdeSite { get; set; }
      public string Type { get; set; }
      public string OwnerName { get; set; }
       
  }

Thanks,
Joe
Radoslav
Telerik team
 answered on 28 Sep 2010
1 answer
96 views
I am working on a specific requirement in Rad grid. Encounter an issue while deleting all the data corresponding to a current filter and reloads the page with the filter expression still in the combo box.

I was hoping to tackle this situation by setting the Current filter value to "All" but not successful.

RadGrid1.MasterTableView.GetColumn("Name").CurrentFilterValue = "All";

But still RadGrid1.MasterTableView.FilterExpression contains the expression for the deleted data. In prevsious version for 3.5 I could handle this situation by replacing the filter expression by string manipulation and setting the filter expression to the radgrid once again. But in the upgraded version targeting .netframework 4.0, this is not possible as the filter expression is different from that of .net 3.5 version and difficult to replace the expired value.

Is there a way to handle the filter expression for data deleted from the database, but the expression still remains in the combo box. I have a number of filter expressions but would like to avoid only those filters which don't have data exists in the database.


Mira
Telerik team
 answered on 28 Sep 2010
1 answer
86 views
Hi Team,

I need to reduce the width of the appointment in the day view.
If the there is only one appointment in the specific day means, the width was too high(as shown in the figure below), but when there is  two or three appointment, it fixes in the day-view precisely.
Like that, i need to control the width of the appointment in the day-view while i'm having single appointment on the particular day.
I've attached the image.


Thanks,
Daniel.B
Peter
Telerik team
 answered on 28 Sep 2010
3 answers
196 views
Hi there

I have a page with a radcombobox and a placeholder. When a new value is selected from the radcombobox a stored procedure runs which returns multiple result sets based on the selected value. For each one of the result sets which contains at least one row, I need to build a dynamic radgrid. The first set of radgrids always display fine, but sometimes when I select a new value I get an "index was out of range error". I've read some articles that say I need to create dynamic radgrids in OnInit, but I can't get the radcombobox selectedindex in there (at least I can't seem to - maybe someone might have an idea on this). Hopefully someone will have come across this issue and be able to assist me.

Thanks

Here's my aspx code:

 

 

<telerik:RadComboBox ID="LabsDDL" runat="server" AutoPostBack="True" DataSourceID="dsLabs"
    DataTextField="Name" DataValueField="DataSourceID" Width="250px" Height="150px"
    Skin="Outlook">
</telerik:RadComboBox>
</br></br>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
    </ContentTemplate>
</asp:UpdatePanel>


Here's my vb code:

Protected Sub LabsDDL_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles LabsDDL.SelectedIndexChanged
    BuildGrids(LabsDDL.SelectedItem.Value)
End Sub
Protected Overrides Sub OnInit(ByVal e As EventArgs)
    PlaceHolder1.Controls.Clear()
End Sub
Protected Sub BuildGrids(ByVal LabID As Integer)
    Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("StagingConnectionString").ConnectionString)
    Dim cmd As New SqlCommand()
    cmd.Connection = conn
    cmd.CommandType = CommandType.StoredProcedure
    cmd.CommandText = "spLookupChecksNew"
    'Create and add a parameter to Parameters collection for the stored procedure.
    cmd.Parameters.Add(New SqlParameter("@Lab", SqlDbType.Int))
    'Assign the search value to the parameter.
    cmd.Parameters("@Lab").Value = LabID
    Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
    Dim ds As New DataSet()
    ds.Clear()
    ds.Tables.Clear()
    da.Fill(ds)
    Dim i As Integer
    i = 0
    'This will fill dataset with three tables.
    For Each DataTable In ds.Tables
        If ds.Tables(i).Rows.Count > 0 Then
            Dim myConn As New SqlConnection(ConfigurationManager.ConnectionStrings("StagingConnectionString").ConnectionString)
            myConn.Open()
            Dim CheckID As Integer
            Dim CheckName As String
            Dim CheckType As Integer
            Dim ColumnName As String
            Dim AssociatedTable As String
            Dim ParmDefinition As String
            CheckID = CInt(ds.Tables(i).Rows(0)(0))
            Dim cmdOptions As New SqlCommand("spGetCheckOptions", myConn)
            cmdOptions.CommandType = CommandType.StoredProcedure
            cmdOptions.Parameters.AddWithValue("@CheckID", CheckID.ToString)
            Dim reader As SqlDataReader = cmdOptions.ExecuteReader()
            While reader.Read
                If (IsDBNull(reader(0))) Then
                    CheckName = ""
                Else
                    CheckName = reader(0).ToString()
                End If
                If (IsDBNull(reader(1))) Then
                    CheckType = 0
                Else
                    CheckType = reader(1)
                End If
                If (IsDBNull(reader(2))) Then
                    ColumnName = ""
                Else
                    ColumnName = reader(2).ToString()
                End If
                If (IsDBNull(reader(3))) Then
                    AssociatedTable = ""
                Else
                    AssociatedTable = reader(3).ToString()
                End If
                If (IsDBNull(reader(5))) Then
                    ParmDefinition = ""
                Else
                    ParmDefinition = reader(5).ToString()
                End If
            End While
            reader.Close()
            cmdOptions.Dispose()
            myConn.Close()
            myConn.Dispose()
            Dim myGridView As New RadGrid
            myGridView = New RadGrid()
            Dim lblMessage As New Literal
            Try
                Dim ltrTableStart As New Literal
                ltrTableStart.Text = "<table><tr><td>"
                Dim ltrTableEnd As New Literal
                ltrTableEnd.Text = "</tr></td></table>"
                Dim literalheader As New Literal
                literalheader.Text = "<div class='AutoShrink'><h5>" & CheckName & "</h5>"
                Dim literalfooter As New Literal
                literalfooter.Text = "</div>"
                myGridView.EnableViewState = False
                myGridView.DataSource = ds.Tables(i)
                Select Case CheckType
                    Case 1
                        Dim templateColumnName As String = ColumnName
                        Dim templateColumn As New GridTemplateColumn()
                        templateColumn.ItemTemplate = New MyTemplate(templateColumnName, LabsDDL.SelectedValue)
                        templateColumn.HeaderText = "Map value" 'templateColumnName
                        templateColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center
                        templateColumn.ItemStyle.VerticalAlign = VerticalAlign.Middle
                        myGridView.Columns.Add(templateColumn)
                End Select
                Dim viewColumnName As String = ColumnName
                Dim viewColumn As New GridTemplateColumn()
                viewColumn.ItemTemplate = New ViewTemplate(viewColumnName, LabsDDL.SelectedValue, ParmDefinition)
                viewColumn.HeaderText = "View Records" 'viewColumnName
                viewColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center
                viewColumn.ItemStyle.VerticalAlign = VerticalAlign.Middle
                myGridView.Columns.Add(viewColumn)
                myGridView.ID = "rgErrors" & i.ToString
                myGridView.Skin = "Outlook"
                myGridView.CssClass = "AutoShrink"
                myGridView.MasterTableView.TableLayout = GridTableLayout.Auto
                myGridView.MasterTableView.CssClass = "AutoShrink"
                myGridView.ClientSettings.Resizing.ClipCellContentOnResize = True
                myGridView.DataBind()
                PlaceHolder1.Controls.Add(ltrTableStart)
                PlaceHolder1.Controls.Add(literalheader)
                PlaceHolder1.Controls.Add(myGridView)
                PlaceHolder1.Controls.Add(literalfooter)
                PlaceHolder1.Controls.Add(ltrTableEnd)
                myConn.Close()
                myConn.Dispose()
                myGridView.MasterTableView.Dispose()
                myGridView.Dispose()
            Catch ex As Exception
                lblMessage.Text = "<h5 style=""color: red"">Error building grid: " & CheckName & " (MESSAGE:" & ex.Message.ToString & ")</h5>"
                PlaceHolder1.Controls.Add(lblMessage)
            End Try
        End If
        i = i + 1
    Next
    cmd.Dispose()
    conn.Close()
    conn.Dispose()
End Sub

This is the stack trace:
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
   System.Collections.ArrayList.get_Item(Int32 index) +7485640
   Telerik.Web.UI.GridColumnCollection.System.Web.UI.IStateManager.SaveViewState() +215
   Telerik.Web.UI.GridTableView.GetStructureState() +257
   Telerik.Web.UI.RadGrid.SaveTableViewStructure(ArrayList stateList, GridTableView tableView) +81
   Telerik.Web.UI.RadGrid.SaveViewState() +128
   System.Web.UI.Control.SaveViewStateRecursive() +187
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Control.SaveViewStateRecursive() +106
   System.Web.UI.Page.SaveAllState() +168
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1099

Pavlina
Telerik team
 answered on 28 Sep 2010
1 answer
468 views
Hi Guys,

I want to be able to hide a column in my table using CSS display:none but the option below does not see to wan to work. I have also tried ClassName="cssProvince". Is there something specific I should be doing?

<telerik:GridBoundColumn class="cssProvince" DataField="Province" HeaderText="Province" ReadOnly="True" SortExpression="Province" UniqueName="Province">

Thanks
James
Dimo
Telerik team
 answered on 28 Sep 2010
3 answers
61 views
Hi Telerik Team,

We have implemented the Telerik Grid control and the grid works fine with fewer number of columns. But we have more number of columns (approx.20) and it is necessary to freeze the first 3 columns not to loose the context of the row data. So could you clarify the following please,
Is the FrozenColumn property of Grid control combined with the following features will be supported
  1. column re-sizing
  2. column re-ordering
  3. column sorting
  4. Auto-fill functionality similar to Google suggest for names for a particular column. Suppose if the frozen column has this feature then the dropdown kind of UI is not visible as it is being hidden by the frozen UI.

We are facing difficulties in implementing above combination of functionalities for Grid control. Your reply and any hot fix will be really useful and highly appreciatable. Looking for your response.

Pavlina
Telerik team
 answered on 28 Sep 2010
7 answers
220 views
Hi.
I have a grid with one combobox and some numerice columns. In edit/insert mode it is not possible to choose any value from the combobox, the combobox is locked and i can not cancel either. (I have to reload the page to get out of the edit/insert mode.) I am using EnableAutomaticLoadOnDemand = true and fill up the combobox in the ItemDataBound events. The code i am using is:

<telerik:RadGrid ID="RadGrid2" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
      AllowFilteringByColumn="True" AllowMultiRowSelection="True" AllowPaging="True" AllowSorting="True" DataSourceID="LinqDataSource1"
      GridLines="None" ondatabound="RadGrid1_DataBound" onitemdatabound="RadGrid1_ItemDataBound"
      onitemdeleted="RadGrid1_ItemDeleted" oniteminserted="RadGrid1_ItemInserted" onitemupdated="RadGrid1_ItemUpdated">
      <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataSourceID="LinqDataSource1" DataKeyNames="Id">
      <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
      <Columns>
          <telerik:GridTemplateColumn DataField="Id" HeaderText="Gruppe" SortExpression="Id" UniqueName="Id" AutoPostBackOnFilter="True" ShowFilterIcon="false">
              <FooterTemplate>Template footer</FooterTemplate><FooterStyle VerticalAlign="Middle" HorizontalAlign="Center" />
              <ItemTemplate><%#DataBinder.Eval(Container.DataItem, "Id")%></ItemTemplate>
              <EditItemTemplate>
              <telerik:RadComboBox DataTextField="Id" DataValueField="Id" ID="RadComboBox1" HighlightTemplatedItems="true" EmptyMessage="Velg et element..." AllowCustomText="true"
                          runat="server" Height="100px" Width="95px" SelectedValue='<%#Bind("Id") %>' AutoPostBack="true" EnableAutomaticLoadOnDemand="True"></telerik:RadComboBox>           
              </EditItemTemplate>
          </telerik:GridTemplateColumn>    
          <telerik:GridNumericColumn DataField="FEE" DataType="System.Double" HeaderText="Avgift" SortExpression="FEE" UniqueName="FEE">
          </telerik:GridNumericColumn>       
          <telerik:GridNumericColumn DataField="PBE" DataType="System.Double" HeaderText="PBE" SortExpression="PBE" UniqueName="PBE">
          </telerik:GridNumericColumn>               
          <telerik:GridEditCommandColumn CancelText="Avbryt" EditText="Endre" InsertText="Sett inn" UpdateText="Oppdater">
          </telerik:GridEditCommandColumn>
          <telerik:GridButtonColumn CommandName="Delete" Text="Slett" UniqueName="column1">
          </telerik:GridButtonColumn>
  </Columns>
  </MasterTableView>
  </telerik:RadGrid>
   
  <asp:LinqDataSource ID="LinqDataSource2" runat="server"
      OnInserting="GridDataSource_Inserting" ContextTypeName="Mobitech.Mtbs2InfoEasy.linq.Mtbs2InfoEasy_DataClassesDataContext"
      TableName="Groups" OrderBy="Id"
      Select="new (Id, FEE, PBE)">
  </asp:LinqDataSource>
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
   if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridDataInsertItem)
   {               
         FillComboBoxWithClassCodes(e, "RadComboBox1");
         SetColumnWidthInInsertMode(e);                   
   }
   else if (!(e.Item is GridDataInsertItem) && e.Item.IsInEditMode)
   {
          FillComboBoxWithClassCodes(e, "RadComboBox1");
          SetColumnWidthInEditMode(e);
          SetFocusOnField(e, "PBE");
   }
}
 
private void FillComboBoxWithClassCodes(GridItemEventArgs e, string comboBoxName)
{
            var editItem = (GridDataItem) e.Item;
            if (editItem == null)
                return;
 
            var comboBox = (RadComboBox) editItem.FindControl(comboBoxName);
            comboBox.Items.Clear();
            
                                var classCodes = new List<string>();
                               for (int i = 1; i < 10; i++)
                              {
                                       classCodes.Add("B0" + i);
                              }
 
 
            foreach (var classCode in classCodes)
            {
                var item = new RadComboBoxItem();
                item.Text = classCode;
                item.Value = classCode;
                comboBox.Items.Add(item);
            }
 
            comboBox.DataBind();
}

I have used equivalent code in another project without problem with loading the combobox. So i don't understand why it is not working. Some have any idea what i am doing wrong?



Tsvetina
Telerik team
 answered on 28 Sep 2010
3 answers
144 views
Hi All,

I am using the Grid and everything works except when the combination of Filtering and Edit is invoked.
Scenario:

I have a grid view where I have filtered a column using the "Contains" field.
With the items in the grid filtered, I click on the edit button which is a "GridEditCommandColumn"

The Edit Popup seems to reference the index of the grid and not the item I have clicked on. Therefore, when clicking the third item of this filtered grid, it results in opening the popup for the third item in the original datasource. Also once clicked on, the grid refreshes and the filters doesn't seem to come into play.

Tim

Iana Tsolova
Telerik team
 answered on 28 Sep 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?