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

I would like to do a client-side binding on radgrid without calling a webservice. all of the examples that I've seen use a webservice...

I want the user to add/remove/edit rows to the RadGrid using an external form (all in javascript) and only when he's done the data will be sent to the server.
My questions are:
1. what is the format of the datasource that I should pass to "set_dataSource"? if I want to bind the data or add a new row. 
   can I do something like: 
   var arr = new Array();
    arr.push( {field1: value1, field2: value2 .... } )
    myGrid.set_dataSource(arr);
    myGrid.data_bind();

2. how do I extract the grid's data and send it back to the server?

Thanks in advanced!
Radoslav
Telerik team
 answered on 16 Sep 2011
4 answers
163 views
Good morning everyone. Here is my problem. I have a DropdownList inside of an edit form template. On ItemDataBound its items' text and values are populated by a stored procedure. This is working perfectly. The problem is what I want to happen next. When the user clicks an item, the item's text and value are sent to the database (SQL Server) as parameters in order to pull more data and populate textboxes within the template. In my old solution it was as easy at using FindControl to find those textboxes on the page and setting their text as equal to whatever was returned. This is proving to be much more difficult using RadGrid, though, as I cannot seem to find a way to actually find those controls to populate their text. I have included my markup for the radgrid and the DropDownList's selectedindexchanged method below:

####MARKUP####
 
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="theSource" AllowPaging="true"
            AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true"
            ExportSettings-Pdf-AllowPrinting="true" ShowStatusBar="true" ShowFooter="true"
            AllowSorting="true" AllowMultiRowEdit="true" ShowGroupPanel="true" OnDeleteCommand="RadGrid1_DeleteCommand"
            CellSpacing="0" GridLines="None" Skin="Web20" AutoGenerateColumns="false"
            OnItemCommand="RadGrid1_ItemCommand" OnInsertCommand="RadGrid1_InsertCommand"
            OnUpdateCommand="RadGrid1_UpdateCommand"
            OnItemInserted="RadGrid1_ItemInserted"
            onitemdatabound="RadGrid1_ItemDataBound">
            <PagerStyle Mode="NextPrevAndNumeric" />
            <ExportSettings IgnorePaging="true" OpenInNewWindow="true">
                <Pdf PageHeight="210mm" PageWidth="297mm" PageTitle="Weekly Goals" DefaultFontFamily="Arial Unicode MS"
                    PageBottomMargin="20mm" PageTopMargin="20mm" PageLeftMargin="20mm" PageRightMargin="20mm" />
            </ExportSettings>
            <MasterTableView EditMode="EditForms" CommandItemDisplay="Top" DataKeyNames="GoalID">
                <%--<CommandItemTemplate>
                <asp:Button ID="DownloadPDF" runat="server" Width="100%" CommandName="ExportToPdf" Text="Export to PDF"
                    CssClass="pdfButton" />
            </CommandItemTemplate>--%>
                <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldName="BeginDate" HeaderText="Begin Date" FormatString="{0:d}" />
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="BeginDate" SortOrder="Descending" />
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
                <Columns>
                    <telerik:GridEditCommandColumn>
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn DataField="GoalID" ReadOnly="true" Display="false" HeaderText="GoalID">
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn DataField="BeginDate" HeaderText="Begin Date" DataFormatString="{0:d}">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridDateTimeColumn DataField="EndDate" HeaderText="End Date" DataFormatString="{0:d}"
                        EditFormColumnIndex="1">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridBoundColumn DataField="GoalName" UniqueName="goalNameTextBox" HeaderText="Goal Name">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="WeeklyGoal" HeaderText="Goal Description" EditFormColumnIndex="1">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="GoalComplete" HeaderText="Goal Complete?"
                        EditFormColumnIndex="2" DefaultInsertValue="false">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumn DataField="Task1" Display="false" HeaderText="Step 1">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="T1Complete" Display="false" HeaderText="Complete"
                        EditFormColumnIndex="0" DefaultInsertValue="false">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumn DataField="Task2" Display="false" HeaderText="Step 2">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="T2Complete" Display="false" HeaderText="Complete"
                        EditFormColumnIndex="0" DefaultInsertValue="false">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumn DataField="Task3" Display="false" HeaderText="Step 3">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="T3Complete" Display="false" HeaderText="Complete"
                        EditFormColumnIndex="0" DefaultInsertValue="false">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumn DataField="Task4" Display="false" HeaderText="Step 4">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="T4Complete" Display="false" HeaderText="Complete"
                        EditFormColumnIndex="0" DefaultInsertValue="false">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumn DataField="Task5" Display="false" HeaderText="Step 5">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="T5Complete" Display="false" HeaderText="Complete"
                        EditFormColumnIndex="0" DefaultInsertValue="false">
                    </telerik:GridCheckBoxColumn>                   
                </Columns>
                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                </RowIndicatorColumn>
                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                </ExpandCollapseColumn>
                <EditFormSettings InsertCaption="Add New Goal" ColumnNumber="3" EditFormType="Template">
                    <FormTemplate>
                        <table id="dateControlsTable" cellspacing="2" cellpadding="2" border="0" rules="none"
                            style="border-collapse: collapse;">
                            <tr class="EditFormHeader">
                                <td colspan="2">
                                    <b>Goal Data</b>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <strong>Begin Date:</strong>
                                    <telerik:RadDatePicker runat="server" Skin="Web20" ID="beginDatePicker" DbSelectedDate="<%# Bind('BeginDate') %>">
                                    </telerik:RadDatePicker>
                                </td>
                                <td>
                                    <strong>End Date:</strong>
                                    <telerik:RadDatePicker runat="server" Skin="Web20" ID="endDatePicker" DbSelectedDate="<%# Bind('EndDate') %>">
                                    </telerik:RadDatePicker>
                                </td>
                                <td>
                                    <asp:HiddenField runat="server" ID="goalIDHF" Value="<%# Bind('GoalID') %>" />
                                </td>
                            </tr>
                        </table>
                        <p>
                        </p>
                        <table id="goalDataTable" cellspacing="2" cellpadding="2" border="0" rules="none"
                            style="border-collapse: collapse;">
                            <tr>
                                <td>
                                    <strong>Goal Name:</strong>
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="goalNameTextBox" Text="<%# Bind('GoalName') %>"
                                        Width="500">
                                    </telerik:RadTextBox>
                                </td>
                                <td>
                                    <strong>Goal Complete:</strong>
                                </td>
                                <td style="text-align: center">
                                    <%--<asp:CheckBox runat="server" ID="goalCompleteCheckBox" Checked="<%# Bind('GoalComplete') %>" />--%>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <strong>Goal Description:</strong>
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="goalDescriptionTextBox" Text="<%# Bind('WeeklyGoal') %>"
                                        Width="500">
                                    </telerik:RadTextBox>
                                </td>
                                <td>
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <strong>Steps</strong>
                                </td>
                                <td>
                                </td>
                                <td>
                                    <strong>Hours</strong>
                                </td>
                                <td style="text-align: center">
                                    <strong>Complete</strong>
                                </td>
                            </tr>
                            <tr>
                                <td style="float: right">
                                    1.
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="step1TextBox" Text="<%# Bind('Task1') %>"
                                        Width="500">
                                    </telerik:RadTextBox>
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="step1HoursTextBox" Text="<%# Bind('T1EstimatedHours') %>"
                                        Width="30">
                                    </telerik:RadTextBox>
                                </td>
                                <td style="text-align: center">
                                    <asp:CheckBox runat="server" ID="step1Complete" Checked="<%# Bind('T1Complete') %>" />
                                </td>
                                <td>
                                    <asp:DropDownList ID="TemplateDropDown" runat="server"
                                            AppendDataBoundItems="True" AutoPostBack="True" CssClass="templateDropDown"
                                            OnSelectedIndexChanged="TemplateDropDown_SelectedIndexChanged"
                                            ViewStateMode="Enabled">
                                            <asp:ListItem Value="0">Choose...</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td style="float: right">
                                    2.
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="step2TextBox" Text="<%# Bind('Task2') %>"
                                        Width="500">
                                    </telerik:RadTextBox>
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="step2HoursTextBox" Text="<%# Bind('T2EstimatedHours') %>"
                                        Width="30">
                                    </telerik:RadTextBox>
                                </td>
                                <td style="text-align: center">
                                    <asp:CheckBox runat="server" ID="step2Complete" Checked="<%# Bind('T2Complete') %>" />
                                </td>
                            </tr>
                            <tr>
                                <td style="float: right">
                                    3.
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="step3TextBox" Text="<%# Bind('Task3') %>"
                                        Width="500">
                                    </telerik:RadTextBox>
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="step3HoursTextBox" Text="<%# Bind('T3EstimatedHours') %>"
                                        Width="30">
                                    </telerik:RadTextBox>
                                </td>
                                <td style="text-align: center">
                                    <asp:CheckBox runat="server" ID="step3Complete" Checked="<%# Bind('T3Complete') %>" />
                                </td>
                            </tr>
                            <tr>
                                <td style="float: right">
                                    4.
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="step4TextBox" Text="<%# Bind('Task4') %>"
                                        Width="500">
                                    </telerik:RadTextBox>
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="step4HoursTextBox" Text="<%# Bind('T4EstimatedHours') %>"
                                        Width="30">
                                    </telerik:RadTextBox>
                                </td>
                                <td style="text-align: center">
                                    <asp:CheckBox runat="server" ID="step4Complete" Checked="<%# Bind('T4Complete') %>" />
                                </td>
                            </tr>
                            <tr>
                                <td style="float: right">
                                    5.
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="step5TextBox" Text="<%# Bind('Task5') %>"
                                        Width="500">
                                    </telerik:RadTextBox>
                                </td>
                                <td>
                                    <telerik:RadTextBox runat="server" Skin="Web20" ID="step5HoursTextBox" Text="<%# Bind('T5EstimatedHours') %>"
                                        Width="30">
                                    </telerik:RadTextBox>
                                </td>
                                <td style="text-align: center">
                                    <asp:CheckBox runat="server" ID="step5Complete" Checked="<%# Bind('T5Complete') %>" />
                                </td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    <asp:LinkButton ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                    </asp:LinkButton> <asp:LinkButton ID="btnCancel" Text="Cancel" runat="server"
                                        CausesValidation="False" UseSubmitBehavior="false" CommandName="Cancel"></asp:LinkButton> <asp:LinkButton
                                            ID="btnDelete" Text="Delete" runat="server" CausesValidation="false" CommandName="Delete" />
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                </EditFormSettings>
            </MasterTableView>
            <FilterMenu EnableImageSprites="False">
            </FilterMenu>
            <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
            </HeaderContextMenu>
        </telerik:RadGrid>
 
####C Sharp####
 
protected void TemplateDropDown_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList TemplateDropDown = (DropDownList)sender;
 
        if (TemplateDropDown.SelectedIndex > 0)
        {
            string templateID = TemplateDropDown.SelectedItem.Value.ToString();
            string templateName = TemplateDropDown.SelectedItem.Text.ToString();
 
            DataTable dt = new DataTable();
            SqlConnection connection = new SqlConnection(GetConnectionString());
            try
            {
                connection.Open();
                SqlCommand cmd = new SqlCommand("RetrieveWeeklyGoalTemplate", connection);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@GoalID", templateID);
                cmd.Parameters.AddWithValue("@TemplateName", templateName);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
 
                da.Fill(dt);
                if (dt.Rows.Count >= 0)  //the greater than or equal to is necessary to delete the last row in the gridview.
                {
                    //GridEditFormItem editform = (GridEditFormItem)sender;
 
                    string estHours1 = dt.Rows[0][2].ToString();
                    string estHours2 = dt.Rows[0][4].ToString();
                    string estHours3 = dt.Rows[0][6].ToString();
                    string estHours4 = dt.Rows[0][8].ToString();
                    string estHours5 = dt.Rows[0][10].ToString();
 
                    valueChecker.valueChecker value = new valueChecker.valueChecker();
 
                    System.Collections.Specialized.ListDictionary templateValues = new System.Collections.Specialized.ListDictionary();
 
                    templateValues["goalNameTextBox"] = dt.Rows[0]["TemplateName"].ToString();
                    templateValues["goalDescriptionTextBox"] = dt.Rows[0]["WeeklyGoal"].ToString();
                    templateValues["step1TextBox"] = dt.Rows[0]["Task1"].ToString();
                    templateValues["step2TextBox"] = dt.Rows[0]["Task2"].ToString();
                    templateValues["step3TextBox"] = dt.Rows[0]["Task3"].ToString();
                    templateValues["step4TextBox"] = dt.Rows[0]["Task4"].ToString();
                    templateValues["step5TextBox"] = dt.Rows[0]["Task5"].ToString();
 
                    Response.Write(RadGrid1.MasterTableView.Items["goalNameTextBox"].ID.ToString());
                  
                    ((TextBox)RadGrid1.MasterTableView.FindControl("goalNameTextBox")).Text = dt.Rows[0]["TemplateName"].ToString();
                    ((TextBox)RadGrid1.MasterTableView.FindControl("goalDescriptionTextBox")).Text = dt.Rows[0]["WeeklyGoal"].ToString();
                    ((TextBox)RadGrid1.MasterTableView.FindControl("step1TextBox")).Text = dt.Rows[0]["Task1"].ToString();
                    ((TextBox)RadGrid1.MasterTableView.FindControl("step1TextBox")).Text = dt.Rows[0]["Task2"].ToString();
                    ((TextBox)RadGrid1.MasterTableView.FindControl("step1TextBox")).Text = dt.Rows[0]["Task3"].ToString();
                    ((TextBox)RadGrid1.MasterTableView.FindControl("step1TextBox")).Text = dt.Rows[0]["Task4"].ToString();
                    ((TextBox)RadGrid1.MasterTableView.FindControl("step1TextBox")).Text = dt.Rows[0]["Task5"].ToString();
                     
                     
                }
                TemplateDropDown.Items.Clear();
                TemplateDropDown.Items.Add(new ListItem("Personal Goal Library...", "0"));
                                 
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                string msg = "Fetch Error:";
                msg += ex.Message;
                throw new Exception(msg);
            }
            finally
            {
                connection.Close();
                connection.Dispose();
            }           
        }
    }
Shinu
Top achievements
Rank 2
 answered on 16 Sep 2011
5 answers
114 views
Dear Telerik!

I found a very useful client-side event "OnClientAppointmentMoving".

I can access the initial appointment's place before dragging stated, and I can see over which timeslot the opaque rectangle (current appointment's location) currently hangs, and I can cancel the motion and send the appointment back where it was.

But my question is: Can I control that moving opaque rectangle from inside this eveny handler?

Why I need that...

Users of my web site must have limited rights for moving appointments. In particular, they must be unable to move the appointments into the past. Nevertheless when they try dragging an appointment into the past it must not just jump back to the place where it had been before the dragging started (what "args.set_cancel(true)" would do). Instead it must move according to my custom logic...

But is it at all possible?

Many thanks!

- Stepan.

Plamen
Telerik team
 answered on 16 Sep 2011
1 answer
115 views
Hello,

I've a RadGrid with EditMode="InPlace". The Grid is based on a DataTable as datasource. When pressing tab on de last field of the last record I would like to update/insert the current and add a new record.
Is that possible with a RadGrid and if so can someone provide me with a sample?

Regards,
  Jos Meerkerk
Marin
Telerik team
 answered on 16 Sep 2011
3 answers
104 views
hi all,

was wondering how to change the for colour of a title bar of Telerik window in .cs file?
Princy
Top achievements
Rank 2
 answered on 16 Sep 2011
2 answers
121 views
Hello,
I created template column and added custom control which has RadAsyncUpload and html button on it. Now when I scroll grid in horizontal direction, I see that control stays at absolute position and won't scroll. Any ideas on why this happens?
Tsvetina
Telerik team
 answered on 16 Sep 2011
1 answer
262 views
Hello Telerik Team ,

Uploading ".doc" files seems to cause an issue. They get stuck on yellow 
for the upload process even though it shows 100%. If you try to continue- 
click save... It does not save the file.Also just got hung up using multiple PDFs, though this is the first time 
with PDFs I've seen this. It would upload one of the PDFs, but rejected the 
other 2 when I did them one at a time.


I think Due to Large File Upload ,It Remove that file from telerik temporary upload files

    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server"
OnClientFileSelected="DoFrameSize" ForeColor="Black" Skin="Sitefinity" Visible="true">
    <Localization Select="Add Files" />
    </telerik:RadAsyncUpload>
    <telerik:RadProgressArea runat="server" ID="RadProgressArea1">
    </telerik:RadProgressArea>

Please Help me with this out as soon as possible

Regards 


Princy
Top achievements
Rank 2
 answered on 16 Sep 2011
2 answers
75 views
Hello,

                I have a aspx page with four ascx controls. In one of the control i have three buttons, one grid and one tree. i have used the radajaxmanager for ajax operation. In one of the button's clientclick function i called doPostBack function. I entire page is refreshed when i called the doPostBack function, ajax is not working in this situation. Please give the solution for this problem.
Velkumar
Top achievements
Rank 2
 answered on 16 Sep 2011
0 answers
147 views
hi all,
 I need some help in designing menus. My menus structure is attached here.
i can achive 60% of the structure using RadMenu. But you can see in the image that SubMenu1 have also Sub Sub Menus. But that need not display below or top of the same level. I need to move the Sub Menu2 and Sub Menu 3 to the right and the SubSub Menus are displayed just right side of the parent like nested.Any method to achieve this?

Akhil Raj
Top achievements
Rank 1
 asked on 16 Sep 2011
2 answers
136 views
Hi,

I have RadGrid  with Hierarchy value .
It is easy to allow me export to PDF.

But my problem is that i want to show my Parent data & Child data in one block in PDF or if it is possible then i want to change parent background color in PDF (not child background color) because i want to show them like this parent has this child.

I have attached two images.

So, how it can be possible??
if any one knows, please reply as soon as possible.  

thank you,
Ronak 
Ronak
Top achievements
Rank 1
 answered on 16 Sep 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
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?