Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
178 views
Hi,

I have a combination key made up by 3 fields (lead_id,location_id,seq_id). I need to increment seq_id in my code-behind before inserting into the table while the first 2 keys stay the same.  Similar to this post but I'm doing in-place editing:

http://www.telerik.com/forums/add-edit-with-user-defined-primary-key

I'm unsure if it's doable but I tried both in-place and GridTemplateColumn as suggested in the post, but couldn't get it to work. I received this error - "Exception has been thrown by the target of an invocation." after it leaves the InsertCommand event.  Is there anything I'm missing to get the seq_id modify and insert to table? I did set ReadOnly="False".

Here's my ascx:
<telerik:RadGrid ID="RadGrid1" runat="server" MasterTableView-EditMode="InPlace" DataSourceID="ObjectDataSource1" OnInsertCommand="RadGrid1_InsertCommand"
    AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" >
    <MasterTableView AllowAutomaticDeletes="False" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AutoGenerateColumns="False" CommandItemDisplay="Top"
        DataKeyNames="lead_id,location_id,seq_id" DataSourceID="ObjectDataSource1">
        <NoRecordsTemplate>
            No Record Exists</NoRecordsTemplate>
        <Columns>
            <telerik:GridBoundColumn DataField="lead_id" DataType="System.Int32" FilterControlAltText="Filter lead_id column" HeaderText="lead_id" ReadOnly="True"
                SortExpression="lead_id" UniqueName="lead_id" Visible="False">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="location_id" DataType="System.Int32" FilterControlAltText="Filter location_id column" HeaderText="location_id" ReadOnly="True"
                SortExpression="location_id" UniqueName="location_id" Visible="False">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="seq_id" DataType="System.Int32" FilterControlAltText="Filter seq_id column" HeaderText="seq_id" ReadOnly="False"
                SortExpression="seq_id" UniqueName="seq_id">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="current_provider" FilterControlAltText="Filter current_provider column" HeaderText="current_provider"
                SortExpression="current_provider" UniqueName="current_provider">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridBoundColumn>
        </Columns>
 
    </MasterTableView>
</telerik:RadGrid>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}"
     SelectMethod="GetData" TypeName="SALTDetailProviderDALTableAdapters.salt_company_providerTableAdapter" UpdateMethod="Update" >
    <DeleteParameters>
        <asp:Parameter Name="Original_lead_id" Type="Int32" />
        <asp:Parameter Name="Original_location_id" Type="Int32" />
        <asp:Parameter Name="Original_seq_id" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="lead_id" Type="Int32" />
        <asp:Parameter Name="location_id" Type="Int32" />
        <asp:Parameter Name="seq_id" Type="Int32" />
        <asp:Parameter Name="current_provider" Type="String" />
        <asp:Parameter Name="contract_exp_dt" Type="DateTime" />
        <asp:Parameter Name="data_type" Type="Int16" />
        <asp:Parameter Name="ld_min" Type="Int32" />
        <asp:Parameter Name="line_cnt" Type="Int32" />
        <asp:Parameter Name="primary_yn" Type="String" />
    </InsertParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="LeadIdLabel" Name="lead_id" PropertyName="Text" Type="Int32" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="current_provider" Type="String" />
        <asp:Parameter Name="contract_exp_dt" Type="DateTime" />
        <asp:Parameter Name="data_type" Type="Int16" />
        <asp:Parameter Name="ld_min" Type="Int32" />
        <asp:Parameter Name="line_cnt" Type="Int32" />
        <asp:Parameter Name="primary_yn" Type="String" />
        <asp:Parameter Name="Original_lead_id" Type="Int32" />
        <asp:Parameter Name="Original_location_id" Type="Int32" />
        <asp:Parameter Name="Original_seq_id" Type="Int32" />
    </UpdateParameters>
</asp:ObjectDataSource>

Here's my code-behind:
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
{
    // Get last item's
    int count = RadGrid1.Items.Count;
    GridDataItem item = RadGrid1.Items[count - 1] as GridDataItem;
 
    // Get last item's provider name
    string providerName = item["current_provider"].Text;
 
    // Add 1 to last item's seq id
    string strSeqid = item["seq_id"].Text;
    int seqid = int.Parse(item["seq_id"].Text) + 1;
 
            
    // item about to get inserted
    GridDataInsertItem insertedItem = (GridDataInsertItem)e.Item;
     
    // Get provider name of the item about to get inserted
    TextBox providerNameTextBox = insertedItem["current_provider"].Controls[0] as TextBox;
    string providerNameInserted = providerNameTextBox.Text;
 
    // Modify the seq id
    (insertedItem["seq_id"].Controls[0] as TextBox).Text = seqid.ToString().Trim();
 
}

Thank you in advance for your help.

Helen







Konstantin Dikov
Telerik team
 answered on 16 Jun 2014
1 answer
191 views
Hi
I realize everything in my project as in your example:

http://www.telerik.com/help/aspnet-ajax/diagram-server-side.html

But if you display the text goes beyond. How can I fix the problem?
Vessy
Telerik team
 answered on 16 Jun 2014
38 answers
1.0K+ views
I have a grid that's set up to enable client selection and multiple row selection and also has a ClientSelectColumn in it.  I would like to enable some specific behavior:

If I click a client row, I would like it to simply add that row to the list of selected rows.  Right now, the only way to do this is to use the checkbox in the ClientSelectColumn.  The problem with this is that a checkbox is a small control, and if you miss your click and end up clicking outside of the checkbox, it clears all previously selected rows and only selects that one row.

I would also like the row click to toggle selection -- click once, it selects.  Click again, it deselects.  Right now, clicking a row will only select, and to deselect you have to use the checkbox, which can introduce the problem above.

I know it's possible to Ctrl-click to select and deselect, but this has a variety of unwanted effects in the browsers.  Firefox adds a border to the table cell that was Ctrl-clicked, and IE selects all the text in that row.

Has anyone figured out a way to have a row select process that's like what I'm seeking?

Josh
Eyup
Telerik team
 answered on 16 Jun 2014
3 answers
342 views
I've been looking through examples and forums and have not seen a clear example of how to bind a RadComboBox using a WebAPI service as the DataSource.  It seems that this would be supported, but I'm not having any luck getting it to work.  Thanks for any help you can provide!
Shinu
Top achievements
Rank 2
 answered on 16 Jun 2014
4 answers
101 views
When I use AutoResizeHeight in an Editor and the editor grows beyond screen size the Editor focus goes to top on first click in the Editors content.
On the second click the focus stays in the right place.

Is this a flaw?

Marc
Ianko
Telerik team
 answered on 16 Jun 2014
1 answer
99 views
Hello,

I'm using OLAP connection to pivot grid. I've noticed that when "Hide Field" option used on freshly added dimension attribute it refresh the grid and doesn't remove the attribute. Please refer this video : https://www.youtube.com/watch?v=m8vRPi0pzvA&feature=youtu.be

Thanks and Regards,
Yohan
Konstantin Dikov
Telerik team
 answered on 16 Jun 2014
5 answers
106 views
Orgchart with Radtooltip  and with out use OnAjaxUpdate event please  provide sample code  asp,.cs code 
Peter Filipov
Telerik team
 answered on 16 Jun 2014
1 answer
103 views
Greetings

I'm currently working on a project with RadGrid.
The website has one page and a RadGrid without any user settings.

By clicking buttons I change the type of the grid, its columns and its data.

Only when I have a Grid with two levels (e.g. DetailView), it's Impossible to replace it with other data that also has two levels.

 For example, let's define:  
A - One Level Grid (e.g. NO DetailView)
B - Grid with two levels  (mastertabalView+DetailView)

A --> B (e.g. replace grid's data that has one level with data of two levels)
RESULT: REPLACEMENT SUCCESS

B --> A
RESULT: REPLACEMENT SUCCESS

B --> B
RESULT: REPLACEMENT FAIL

B --> A --> B
RESULT: REPLACEMENT FAILS

ASPX:
<telerik:RadGrid ID="RadGrid1" Height="100%" runat="server" EnableHeaderContextMenu="true">
     <ClientSettings>
                <Scrolling AllowScroll="True"></Scrolling>
            </ClientSettings>
 
</telerik:RadGrid>


VB.NET:
001.    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
002.        If Not IsPostBack Then
003.            Session("st") = Nothing
004.            Session("IsGridToBEShowen_flag") = 0
005.        End If
006.    End Sub
007. 
008. 
009.    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
010.        Session("Report_ID") = 1
011.        ReplaceReport
012.    End Sub
013.     
014.     
015.        Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
016.        Session("Report_ID") = 2
017.        ReplaceReport
018.    End Sub
019.     
020.        Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
021.        Session("Report_ID") = 3
022.        ReplaceReport
023.    End Sub
024. 
025.     
026. 
027.Private Sub ReplaceReport()
028.        
029.        rep.ID = Session("Report_ID")
030. 
031. 
032.        Pre_Report()
033.        setGridProperties()
034. 
035.        End_Set_Report()
036.       
037.    End Sub
038.''''''''''''''''''''''''''''''''''''''''''
039. 
040.    Private Sub Pre_Report()
041.        RadGrid1.Enabled = True
042.        RadGrid1.Visible = True
043.        Session("st") = Nothing
044.        Session("isGridInit") = True
045.             
046.        Session("st") = rep.Data  'get specific DataSet into Session
047.    End Sub
048. 
049.    Private Sub End_Set_Report()
050.        
051.        RadGrid1.DataSource = CType(Session("st"), DataSet).Tables(0)
052.       
053.        RadGrid1.DataBind()
054.        RadGrid1.Rebind()
055.        Session("IsGridToBEShowen_flag") = 1
056. 
057.    End Sub
058.     
059.    ''''''''''''''''''''
060.    ''''''''''''''''''''''''''''''''''''''''''''
061.    Private Sub setGridProperties()
062. 
063.        'set grid columns properties
064.        If Session("RTL") Then
065.            RadGrid1.MasterTableView.Dir = GridTableTextDirection.RTL
066.        Else
067.            RadGrid1.MasterTableView.Dir = GridTableTextDirection.LTR
068.        End If
069.        
070.        If RadGrid1.MasterTableView.DetailTables.Count > 0 Then
071.            RadGrid1.MasterTableView.DetailTables(0).DataSource = Nothing
072.            RadGrid1.MasterTableView.DetailTables(0).DataSource = New Object() {}
073.            RadGrid1.MasterTableView.DetailTables(0).Rebind()
074.            
075.            RadGrid1.MasterTableView.DetailTables.Remove(0)
076.        End If
077.        
078.        Dim Number_Of_Tables As Integer = CType(Session("st"), DataSet).Tables.Count
079. 
080.        If Number_Of_Tables = 2 Then
081.            RadGrid1.DataSource = Nothing
082.            RadGrid1.Rebind()
083.            'add details View
084.            Dim detailsView1 As GridTableView = New GridTableView()
085.            detailsView1.Name = "Details"
086.            detailsView1.DataKeyNames = New String() {"Internal_ID"}
087.            RadGrid1.MasterTableView.DetailTables.Add(detailsView1)
088.            RadGrid1.MasterTableView.DataKeyNames = New String() {"Internal_ID"}
089.            RadGrid1.Rebind()
090. 
091.        End If
092. 
093. 
094.        RadGrid1.MasterTableView.TableLayout = GridTableLayout.Fixed
095.        RadGrid1.ClientSettings.Selecting.AllowRowSelect = True
096.        RadGrid1.AllowSorting = True
097.        RadGrid1.AllowPaging = True
098.        RadGrid1.AllowMultiRowSelection = True
099.        RadGrid1.ClientSettings.Scrolling.UseStaticHeaders = True
100.        RadGrid1.ShowHeader = True
101.        RadGrid1.AllowFilteringByColumn = True
102.        RadGrid1.MasterTableView.AllowFilteringByColumn = True
103.        RadGrid1.ClientSettings.AllowDragToGroup = True
104.        RadGrid1.ShowGroupPanel = True
105.        RadGrid1.MasterTableView.HeaderStyle.Width = Unit.Pixel(200)
106. 
107.        RadGrid1.ClientSettings.Selecting.UseClientSelectColumnOnly = True
108.        RadGrid1.ClientSettings.EnableRowHoverStyle = True
109.    End Sub
110. 
111.    Private Sub FirstSortGrid(colum_name As String)
112.        Dim expression As GridSortExpression = New GridSortExpression()
113.        expression.FieldName = colum_name
114.        expression.SortOrder = GridSortOrder.Ascending
115.        RadGrid1.MasterTableView.SortExpressions.AddSortExpression(expression)
116.        Session("isGridInit") = False
117.    End Sub
118.     
119.     Protected Sub RadGrid1_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
120. 
121.        Dim fl As Integer = Session("IsGridToBEShowen_flag")
122.        If fl = 1 Then
123.            RadGrid1.DataSource = CType(Session("st"), DataSet).Tables(0)
124. 
125.        End If
126. 
127.    End Sub
128.     
129.     
130.     
131.     Private Sub RadGrid1_DetailTableDataBind(sender As Object, e As GridDetailTableDataBindEventArgs) Handles RadGrid1.DetailTableDataBind
132.        Dim dataItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)
133.        Select Case e.DetailTableView.Name
134.            Case "Details"
135.                Dim ConnectID As String = dataItem.GetDataKeyValue("Internal_ID").ToString()
136.                CType(Session("st"), DataSet).Tables(1).DefaultView.RowFilter = ""
137.                CType(Session("st"), DataSet).Tables(1).DefaultView.RowFilter = "Internal_ID = " & ConnectID
138.                e.DetailTableView.DataSource = CType(Session("st"), DataSet).Tables(1).DefaultView
139.        End Select
140.    End Sub

Thanks,

Daniel






Kostadin
Telerik team
 answered on 16 Jun 2014
6 answers
121 views
I'm using IE8, version of Telerik.Web.UI is 2010.2.836.35.
In our application when Editor is opened under specific conditions, I receive next javascript error:

  Invalid argument.  

  Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3a1f68db6e-ab92-4c56-8744-13e09bf43565%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2010.2.826.35%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3a86f56c91-febb-4172-ae71-6c2ba2372421%3a16e4e7cd%3a86526ba7%3a874f8ea2%3af7645509%3a24ee1bba%3adc7e0bd%3a1569bb5f%3a63b115ed%3a1c565fc%3a30f1f089%3a19620875%3a490a9d4e, 
 
line 8464 character 1

In Chrome and Firefox I do not get this error.
Using IE debugger, I can see that error happens in next two lines:
http://clip2net.com/clip/m71805/1308143195-clip-49kb.png

Note, that function _fixIEHeight goes after height was assigned. So, if height was negative (as in my case), Invalid argument error is thrown, and I have no possibility to check what this height mean because js is obfuscated.
If we have this _fixIEHeight call before assigning the value, everything should be good, as function really fixes wrong values.

Now I can't give you easy scenario to reproduce, as RadEditor is highly tied with our application. Please reply if the information above makes any sense.
Ianko
Telerik team
 answered on 16 Jun 2014
4 answers
107 views
Why are the buttons used on the standard dialogs for the Hay skin using, what appear to be, the sprites from the black skin?

I use a version of the Hay skin throughout my application including use of the FormDecorator control to make the buttons 'fit', visually. Sadly the buttons on the build-in dialogs stand out like something that stands out a lot.

I've not checked but I'd not be surprised to discover that it's not just the Hay skin that is victim to those big, ugly buttons.

--
Stuart
Shinu
Top achievements
Rank 2
 answered on 16 Jun 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?