Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
105 views
As a follow up to the earlier question beneath, I'm trying to write some code to assign contacts to facilities.

http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-reference-parent-data-items-in-edititemtemplate.aspx

I'm following samples such as the one beneath but I'm unable to find the correct event that I need to use. I'm currently trying to use 'RadGrid1_InsertCommand' but I imagine that's not working because it's the event that would be used for inserting the parent 'Facilities'.

http://www.telerik.com/community/code-library/aspnet-ajax/grid/automatic-operations-in-hierarchical-grid-with-sqldatasource-control.aspx

Can someone tell me what event I need to be looking at?

Thanks,
Tim


Protected Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs)
 
    'This event is not firing when I click on the 'Insert' link. What event do I need to use instead?
 
    Dim insertedItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)
 
    Dim parentItem As GridDataItem = e.Item.OwnerTableView.ParentItem
    Dim datakey As String = parentItem.OwnerTableView.DataKeyValues(parentItem.ItemIndex)("FacilityID").ToString()
    Dim contactId As Integer = (TryCast(insertedItem("colContactId").Controls(0), DropDownList)).SelectedValue
 
    Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
 
    Try
        conn.Open()
 
        Dim insertQuery As String = "INSERT into FacilityContacts(FacilityId, ContactID) values('" & datakey & "','" & contactId & "')"
        Dim cmd As New SqlCommand(insertQuery, conn)
        cmd.ExecuteNonQuery()
        conn.Close()
 
    Catch ex As Exception
        RadGrid1.Controls.Add(New LiteralControl("Unable to insert contact. Reason: " + ex.Message))
        e.Canceled = True
    Finally
    End Try
 
 
End Sub

<telerik:RadGrid ID="RadGrid1" ShowStatusBar="True" DataSourceID="dsFacilityList"
    runat="server" PageSize="7" AllowSorting="True" AllowPaging="True" GridLines="None"
    CellSpacing="0" AllowAutomaticInserts="True"
    AllowAutomaticUpdates="True" >
    <PagerStyle Mode="NumericPages"></PagerStyle>
    <MasterTableView DataSourceID="dsFacilityList" AllowMultiColumnSorting="True"
        PageSize="20" CommandItemDisplay="Top" DataKeyNames="FacilityID" EditMode="EditForms" >
        <EditItemTemplate>
 
        </EditItemTemplate>
        <DetailTables>
            <telerik:GridTableView runat="server" DataKeyNames="FacilityID"
                DataSourceID="dsFacilityContactList" CommandItemDisplay="Top"
                AutoGenerateColumns="False" AllowAutomaticDeletes="True"
                AllowAutomaticInserts="False">                   
                 
                <EditItemTemplate>
               
                </EditItemTemplate>
                 
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="FacilityID"
                        MasterKeyField="FacilityID" />
                </ParentTableRelation>
                <CommandItemSettings ExportToPdfText="Export to PDF" />
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                    <HeaderStyle Width="20px" />
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridTemplateColumn DataField="ContactID"
                        FilterControlAltText="Filter column column" UniqueName="colContactId" EditFormHeaderTextFormat="">
                        <EditItemTemplate>
                               Select Contact:
                                    <asp:DropDownList ID="cboContactID" runat="server">
                                   </asp:DropDownList>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="ContactIDLabel" runat="server" Text='<%# Eval("ContactLongDesc") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
 
                </Columns>
                <EditFormSettings>
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                </EditFormSettings>
            </telerik:GridTableView>
        </DetailTables>
        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"
            Visible="True">
        </ExpandCollapseColumn>
        <SortExpressions>
 
        </SortExpressions>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
     
    </MasterTableView>
 
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
    </HeaderContextMenu>
</telerik:RadGrid>

Tim
Top achievements
Rank 1
 answered on 07 Jul 2011
1 answer
112 views
Hi,
Can you please tel me how to validate the DataDescription Fields and Some others Custom Fields Which we added in Scheduler, I m using Defalut Data Forms.
Plamen
Telerik team
 answered on 07 Jul 2011
1 answer
83 views
2011 Q2, the default loading panel that blocks the entire grid when grid is refreshing takes a long time over RDP beause it paints each line by line of the "block". 

Is there a way to optimize this behavior other than changing the loading panel for all?    When viewing over LAN it's fine.

IE8 is noticeably slower than FF5.
Pavel
Telerik team
 answered on 07 Jul 2011
1 answer
310 views
I'm populating information from a webservice into a radcombobox in asp.net.  I would like to force a line break for certain items to clean up the dropdown information.

No matter what I put in the text field, it always just renders the text and never actually creates a line break.  I looked into creating an itemtemplate for the combobox, but from what I've read, it's not worth the effort when using a webservice.

Is there an escape character that I could use to force a line break?

Thanks,
Javier
Javier
Top achievements
Rank 1
 answered on 07 Jul 2011
2 answers
217 views

I have a RadGrid where I'm truncating the display of cell data in order to preserve page real estate.  I want to show the full cell content in a RadToolTip.

On the server, in the GridItemDataBound server-side event handler, I'm transforming the values of each cell for display.  On the client, I'm truncating the display data using text-overflow:ellipsis.  On the server, I'm creating a RadToolTip with the full value, and shoving it into the Page object's Controls collection:

var item = (GridDataItem)e.Item;
var cell = item["Flavor"];
cell.Text = reallyLongFlavorNameValue;

var tooltip = new RadToolTip();
tooltip.Title = "Flavor";
tooltip.Text = reallyLongFlavorNameValue;
tooltip.TargetControlID = cell.ID;
tooltip.IsClientID = false;
tooltip.RelativeTo = ToolTipRelativeDisplay.Element;
this.Controls.Add(tooltip);

I'm assuming the rest of the values can be defaults.

However, when I show the page, the tooltip never shows. 

What am I missing?


Thanks
KN425000
Top achievements
Rank 1
 answered on 07 Jul 2011
2 answers
129 views
Hi. A few questions about the Sharepoint Acceleration Kit:
  • In the regular editor available in Sharepoint 2010, when we choose to insert an image in a page, there's no easy way to choose an image from the "Site Assets"; we have to upload the image every time from our computer or copy/paste the image URL. Does the SAK tool provide an easy way to choose an image from the Site Assets (or other library)?
  • I've read that the CTP will move to a final release later this year. Is that true?
Thank you :)
Alex
Top achievements
Rank 1
 answered on 07 Jul 2011
3 answers
114 views
Hi,

I'm having some small problems with RadGrid.

Issue 1:
Here is an example page
http://dev2.spireweb.no/resultat.aspx?pid=15&rb=1&type=simpel&q=test
When I fill in a value in the textbox the first time and then I click "Kjøp" then it does not find the value of the textbox, and just add 1 item to cart (handlevogn), but the second time I click "kjøp" it finds the value enter in the textbox.
Here is my ItemCommand code:
protected void radResult_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
    switch (e.CommandName)
    {
        case "AddToCart":
            int test = e.Item.DataSetIndex;
            TextBox txtQuantity = (TextBox)(e.Item.FindControl("txtQuantity"));
            if (txtQuantity.Text.Length > 0)
                ShoppingCart.GetCurrentUsersCart.AddItem(int.Parse(e.CommandArgument.ToString()), int.Parse(txtQuantity.Text.ToString()));
            else
                ShoppingCart.GetCurrentUsersCart.AddItem(int.Parse(e.CommandArgument.ToString()), 1);
            txtQuantity.Text = "";
             
            RadAjaxManager1.ResponseScripts.Add("javascript:updateCart();");
            //RadAjaxManager1.ResponseScripts.Add(string.Format("alert('Hello from the server! Server time is {0}');", DateTime.Now.ToLongTimeString()));
            break;
    }
}

Why do this happen?

Issue 2:
Who can I "reset" the sort, so it goes back to first sort state?
Here is an example page:
http://dev2.spireweb.no/resultat.aspx?pid=15&rb=2&type=simpel&q=test
If I click "Vis treff A-Ã…" how can I go back to the sort state the radgrid started with?

Thanks in advaned...
Marin
Telerik team
 answered on 07 Jul 2011
4 answers
558 views
Hi All

I am calling the insert form of radgrid using the fireCommand from javascript that is triggered by and external button,
However seeing as i am using a custom command name it will not trigger unless the grid has some data,
I tried changing the command name to InitInsert....however this does not trigger the grids Item_command server side for some reason!

I need to trigger the Item_command as i need to control the event.

Could someone tell me why this is not triggering using InitInsert and it triggered using my custom command?

Many Thanks

Regards

Cush
Cush
Top achievements
Rank 1
 answered on 07 Jul 2011
8 answers
195 views
Hi,
I'm using the "Client edit with batch server update" example to make my own grid. I have a question that I haven't found the solution. How can I insert a new row using gridTemplatecolumns? I have add a command Item Template linkButton element for the inserting, but when I click on it, it is only appearing for inserting a column that is a bound one. How can I do for Inserting items using template columns?
I'm trying to work in server-side all I can.
Thanks,
Jon
Ja
Top achievements
Rank 1
 answered on 07 Jul 2011
1 answer
113 views
Hi Telerik
I have a colour scheme for my line chart - however this colour scheme does not translate very well when printed in black and white. One option is to set one of my lines to use a penstyle other than solid and this works quite well. However the legend doesn't reflect this and having printed the chart in b&w, the user is no wiser as to which chart series is which - they can see one is dotted (or dashdot etc), they just can't tell which one from the legend.

Is there a way to style the legend to reflect this?  By default the legend items are shown as squares, so this would need to change to a line or something in order for the penstyle to be visible.

thanks
--Mike
Evgenia
Telerik team
 answered on 07 Jul 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?