Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
134 views
What I'm trying to accomplish is quite simple but I still didn't grasp all the ways of iterating the grid items in all the events.
I have a grid with a custom FormView inside <NestedViewTemplate> (well the FormView really is inside a user control in <NestedViewTemplate>).

What I would like to happen in the gui is this: when you click on the edit button (wich triggers a custom edit logic) I would like to check all OTHER rows to see if:
1) they are expanded (and in this case collapse them so that only the active edited row is expanded)
2) set the FormView.FormViewMode of each row OTHER than the edited one to ReadOnly so that if the user opens the row again in a later moment he finds it in view mode and no more in edit mode.
3) set the <asp:Panel runat="server" ID="RadGrid1DetailContainer" CssClass="RadGridDetailContainer" Visible="true">, wich is the first item in the <NestedViewTemplate> to visible = false for all the row OTHER than the edited one

The expand part is easy, and the custom logic wich expands the edited row and sets the FormView in edit mode is easy but I cannot find a way to address points 2 and 3.

Here is my logic so far that triggers in RadGrid1_ItemCommand when user clicks on the edit button and throws the EditFormView command. 

ASPX part:

<NestedViewTemplate>
    <asp:Panel runat="server" ID="RadGrid1DetailContainer" CssClass="RadGridDetailContainer" Visible="true">
        <telerik:RadTabStrip runat="server" ID="RadGrid1DetailTabStrip" MultiPageID="RadGrid1DetailMultipage1" SelectedIndex="0" CssClass="RadGridTabStrip">
            <Tabs>
                <telerik:RadTab runat="server" Text="Dati utente" PageViewID="RadGrid1DetailRadPageView1">
                </telerik:RadTab>
                <telerik:RadTab runat="server" Text="Anagrafica" PageViewID="RadGrid1DetailRadPageView2">
                </telerik:RadTab>
                <telerik:RadTab runat="server" Text="Altri dati" PageViewID="RadGrid1DetailRadPageView3">
                </telerik:RadTab>
            </Tabs>
        </telerik:RadTabStrip>
        <telerik:RadMultiPage runat="server" ID="RadGrid1DetailMultipage1" SelectedIndex="0" RenderSelectedPageOnly="false">
            <telerik:RadPageView runat="server" ID="RadGrid1DetailRadPageView1" CssClass="RadGridPageView">
                <asp:FormView id="RadGrid1DetailForm1" CssClass="RadGridDetailForm" runat="server">
                    <ItemTemplate>
                        <div class="form-horizontal form-stripe" style="padding: 12px;">
                            <eva:FormUserDetail ID="FormUserDetail1" Item="<%# Container.DataItem %>" View="Detail1" runat="server" />
                            <div class="form-actions">
                               <asp:LinkButton ID="FormConfirmUpdate" runat="server" CssClass="btn btn-primary" CommandName="EditFormView">
                                    <i class="icon icon-pencil"></i> Edit
                                </asp:LinkButton>
                           </div>
                        </div>
                    </ItemTemplate>
 
                    <EditItemTemplate>
                        <div class="form-horizontal form-stripe" style="padding: 12px;">
                            <eva:FormUserEdit ID="FormUserDetail2" Item="<%# Container.DataItem %>" View="Detail1" runat="server" />
                            <div class="form-actions">
                              <asp:Button runat="server" ID="FormConfirmUpdate" CssClass="btn btn-success" Text="Submit" CommandName="FormConfirmUpdate" />
                               <asp:Button runat="server" ID="FormCancelUpdate" CssClass="btn" Text="Cancel" CommandName="FormCancelUpdate" />
                            </div>
                        </div>
                    </EditItemTemplate>
                </asp:FormView>
            </telerik:RadPageView>
 
            <telerik:RadPageView runat="server" ID="RadGrid1DetailRadPageView2">
 
            </telerik:RadPageView>
            <telerik:RadPageView runat="server" ID="RadGrid1DetailRadPageView3">
 
            </telerik:RadPageView>
        </telerik:RadMultiPage>
    </asp:Panel>
</NestedViewTemplate>

The code behind for the EditFormView command is:

Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.ItemCommand
    Dim gridFormView As FormView
    Dim primaryKey As Integer
  
    If TypeOf (e.Item) Is GridDataItem Then
        gridFormView = DirectCast(e.Item, GridDataItem).ChildItem.FindControl("RadGrid1DetailContainer").FindControl("RadGrid1DetailMultipage1").FindControl("RadGrid1DetailRadPageView1").FindControl("RadGrid1DetailForm1")
        primaryKey = Convert.ToInt32(DirectCast(e.Item, GridDataItem).GetDataKeyValue("UserId"))
    End If
  
    Select Case e.CommandName
        Case "EditFormView"
            e.Item.Expanded = True
  
            If TypeOf (e.Item) Is GridDataItem Then
                DirectCast(e.Item, GridDataItem).ChildItem.FindControl("RadGrid1DetailContainer").Visible = True
  
                ' Collapse all other opened details
                For Each item As GridItem In e.Item.OwnerTableView.Items
                    If item.Expanded AndAlso Not item Is e.Item Then
                        item.Expanded = False
                        DirectCast(item.DataItem, GridDataItem).ChildItem.FindControl("RadGrid1DetailContainer").Visible = False
  
                        Dim gridFormViewToBeClosed As FormView = DirectCast(item.DataItem, GridDataItem).ChildItem.FindControl("RadGrid1DetailContainer").FindControl("RadGrid1DetailMultipage1").FindControl("RadGrid1DetailRadPageView1").FindControl("RadGrid1DetailForm1")
  
                        ' Put form always in ReadOnly when is expanded
                        If gridFormViewToBeClosed.CurrentMode <> FormViewMode.ReadOnly Then
                            gridFormViewToBeClosed.ChangeMode(FormViewMode.ReadOnly)
                        End If
                    End If
                Next item
            End If
  
            ' Put form in EditMode when is expanded
            If gridFormView.CurrentMode <> FormViewMode.Edit Then
                gridFormView.ChangeMode(FormViewMode.Edit)
            End If
  
            ' Fill the form view from the db
            SelectUserEdit(primaryKey, gridFormView)
    End Select
End Sub

The item.Expanded = False part works like expected. The issue I'm facing is how to retrieve a reference to the FormView(s) and to the RadGrid1DetailContainer  for each other row

I tried with 
DirectCast(item.DataItem, GridDataItem).ChildItem.FindControl("RadGrid1DetailContainer").Visible = False
But I guess item.DataItem is not what I'm looking for since I always have a  System.NullReferenceException on that line... 

Any hint on how to iterate and access the FormView in all the rows other than the one where the click command triggered, would be greatly appreciated. 

Thanks in advance




Marin
Telerik team
 answered on 13 Nov 2013
1 answer
188 views
<script type="text/javascript">
    function OnClientFileOpen(oExplorer, args)
    {
        //get the extension of the opened item
        var fileExt = args.get_item().get_extension();
        if (fileExt && fileExt.toLowerCase() == "pdf")
        {
            //cancel the default behavior
            args.set_cancel(true);
            //open new RadWindow
            var oWnd = radopen(args.get_item().get_path(), "RadWindow1");
            //set size to the newly opened RadWindow
            oWnd.setSize(600, 400);
            //if you want to open the PDF file in a new browser window
            //you can use the following code
            //window.open(args.get_item().get_path());
        }
    }
</script>


I am getting "The resource cannot be found." error when i use UNC path and the above javascript. Is there any solution for this problem?

Thanks
Corey
Top achievements
Rank 1
 answered on 13 Nov 2013
1 answer
215 views
I have a radnumerictextbox in one column of a radgrid and a label in another column of the same radgrid.

I'm trying to calculate the value of the label when the radnumerictextbox changes. If I set up the event handler clientside it fires the event, but I don't know how to figure out what row in the radgrid to update the value in. If I try to set up the handler in the itemcreated event of the radgrid, it fires the function right away.( I assume this is because of the parenthesis). Here is the code snippets. Any ideas?

 

 

<telerik:RadGrid runat="server" ID="RewardProductsGrid" EnableViewState="True" ShowStatusBar="False" ShowFooter="False"
 
 DataSourceID="RewardProductsSource" ShowHeader="False"
 
 OnItemDataBound="RewardProductsGrid_OnItemDataBound"
 
 OnItemCreated="RewardProductsGrid_OnItemCreated">
 
 <ClientSettings EnableAlternatingItems="False" ></ClientSettings>
 
 <mastertableview autogeneratecolumns="False" datakeynames="ProductId"
 
 editmode="EditForms" nomasterrecordstext="No orders found." allowsorting="False"
 
 allowmulticolumnsorting="False">
 
 <Columns>
 
 <telerik:GridTemplateColumn AllowFiltering="False">
 
 <ItemTemplate>
 
 <asp:Image runat="server" ImageUrl='<%# ((Product)Container.DataItem).CartImageUrl %>'/>
 
 </ItemTemplate>
 
 </telerik:GridTemplateColumn>
 
 <telerik:GridTemplateColumn AllowFiltering="False">
 
 <ItemTemplate>
 
 <asp:Label runat="server" ID="ProductNameLabel" Text='<%# ((Product)Container.DataItem).NameLocalized %>'></asp:Label><br/>
 
 <asp:Label runat="server" ID="ItemNumberLabel"></asp:Label>:#<asp:Label runat="server" ID="ItemNumber" Text='<%# ((Product)Container.DataItem).ProductNumber %>'></asp:Label>
 
 </ItemTemplate>
 
 </telerik:GridTemplateColumn>
 
 <telerik:GridTemplateColumn AllowFiltering="False">
 
 <ItemTemplate>
 
 <asp:Label runat="server" ID="PointsLabel"></asp:Label>:<br/>
 
 <asp:Label runat="server" ID="Points" Text='<%# String.Format("{0:#}",((Product)Container.DataItem).CurrentRewardPointPrice) %>'></asp:Label>
 
 </ItemTemplate>
 
 </telerik:GridTemplateColumn>
 
 <telerik:GridTemplateColumn AllowFiltering="False">
 
 <ItemTemplate>
 
 <asp:Label runat="server" ID="QuantityLabel"></asp:Label>:<br/>
 
 <telerik:RadNumericTextBox runat="server" ID="QuantityTextBox" Value="1" MaxValue="10" MinValue="1">
 
 <NumberFormat DecimalDigits="0"></NumberFormat>
 
 <%-- <ClientEvents OnValueChanged="QuantityTextBoxValueChanged"></ClientEvents>--%>
 
 </telerik:RadNumericTextBox>
 
 </ItemTemplate>
 
 </telerik:GridTemplateColumn>
 
 <telerik:GridTemplateColumn AllowFiltering="False">
 
 <ItemTemplate>
 
 <asp:Label runat="server" ID="ItemTotalLabel"></asp:Label>:<br/>
 
 <asp:Label runat="server" ID="ItemTotal"></asp:Label>
 
 </ItemTemplate>
 
 </telerik:GridTemplateColumn>
 
 </Columns>
 
 </mastertableview>
 
 </telerik:RadGrid>
 
 
protected void RewardProductsGrid_OnItemCreated(object sender, GridItemEventArgs e)
 
{
 
 if (e.Item is GridDataItem)
 
{
 
 GridDataItem item = (GridDataItem)e.Item;
 RadNumericTextBox radNumericTextBox = (RadNumericTextBox)item.FindControl("QuantityTextBox");
 // chkBox.Attributes.Add("onclick", "clicked_chkBox('" + item.ItemIndex + "')");
 radNumericTextBox.ClientEvents.OnValueChanged = "change_quantity('" + item.ItemIndex + "')";
}
 
}
<telerik:RadScriptBlock ID="RadGridScriptBlock" runat="server">
<script type="text/javascript">
 
function CloseActiveToolTip() {
setTimeout(function () {
var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();
if (tooltip) tooltip.hide();
}, 1000);
}
 
function refreshGrid() {
var masterTable = $find("<%= RewardProductsGrid.ClientID %>").get_masterTableView();
masterTable.rebind();
}
 
 function QuantityTextBoxValueChanged(sender, args) {
 alert("Test");
 alert(sender.get_value());
}
 function change_quantity(index) {
 alert(index);
}
</script>
</telerik:RadScriptBlock>

 

 

Dash
Top achievements
Rank 1
 answered on 13 Nov 2013
2 answers
62 views
This has been going on for a long time, just taking time to post now because I'm getting a little tired of it...

I get notifications regularly that I have updates to my Telerik products, only to find, when I launch the Control Panel, that I do not.  How do I resolve this?  Please see the attached screenshots.  You'll see I get a bubble saying I have 4 updates available.  Then I click it and get the popup with the updates listed.  If I launch the CP I see that I do not have 4 updates (in this case I did have one, but often I have NONE). 

PLEASE fix these issues with the Control Panel!
Software
Top achievements
Rank 1
 answered on 13 Nov 2013
4 answers
816 views
Hi

When the asyncupload displays the client uploaded filenames, is it possible to display an icon along with it? My users upload either pdf or doc/docx files, so based on file type can I show separate icons along with file name?
Jane
Top achievements
Rank 1
 answered on 13 Nov 2013
2 answers
95 views
Hi,

Is there a way to do this from outside the bottom of the Grid's PagerTemplate?  Say from a dropdown of page numbers or a Next/Previous button elsewhere on the page.  For instance, my grid's page "1" has the following script reference when I mouse over it...

javascript:__doPostBack('ctl00$PageContent$MySearchControl$grdSearchResult$ctl00$ctl03$ctl01$ctl01','')


I know there the GetPostBackEventReference method, but I'm not sure how to use it with my Grid's pager.

Thanks, Dave.
David
Top achievements
Rank 1
 answered on 13 Nov 2013
1 answer
126 views
Hi guys
How can I clear the incorrect captcha label on clicking the refresh captcha link?

Karl.
Princy
Top achievements
Rank 2
 answered on 13 Nov 2013
1 answer
659 views
Hello,

I have a RadComboBox control. In that, am displaying (eg:Name). But now i need to display name and age etc for the same student.
The data is from database and fetching using the linq query as list of objects.
Please let me know how can I do this.

Regards,
Kothai 
Shinu
Top achievements
Rank 2
 answered on 13 Nov 2013
1 answer
35 views
I have kind of a strange issue with radcombobox and the IE "Stop Running this Script"  issue....

<div>
   <radcombobox>
   <radsplitter>
      <radpane>
          <radtreeview>
      <radpane>
         <radgrid>


I have a treeview and grid on the page ... I drag drop item from the treeview it does a little dance in the background and adds a new column to the grid. Then go to my combobox which is using custom text type 3 characters and the list loads ... I select an item and get the "Stop Running this Script" method - there are only a few results not thousands it is on the 'selection' that it crashes.

I know how this works with telerik 3 days from now rather than answer the question you're going to respond with another question asking me to post all of our proprietary source code or somehow detach all of the propriety code from the project to provide you with a sample of exactly what I described above.... so I'm just going to throw the question out there anyway in the hope someone out there has experienced a similar issue and can be of help.
Hristo Valyavicharski
Telerik team
 answered on 13 Nov 2013
3 answers
165 views
Any idea when your Ajax product will support VS 2013. I know your defcraft supports it already but I am talking about your regular product.
Dyanko
Telerik team
 answered on 13 Nov 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?