This is a migrated thread and some comments may be shown as answers.

Update RadGrid from Radwindow using Drag And Drop

3 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
omar treviño
Top achievements
Rank 1
omar treviño asked on 29 Mar 2010, 03:49 PM

Hi Telerik team, I have the following problem.

I'm using Drag and drop in my solution and works perfect, but I have the option to UPDATE the RadGrid (original) from a RadWindow.

I don't know where is the problem, because in other radgrid without drag and drop works perfect,here is my code:

This is the main page:

 

<

telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">

 

 

 

 

 

 

<AjaxSettings>

 

 

 

 

 

 

<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">

 

 

 

 

 

 

<UpdatedControls>

 

 

 

 

 

 

 

<telerik:AjaxUpdatedControl ControlID="Gridfungenericasoriginal" />

 

 

 

 

 

 

</UpdatedControls>

 

 

 

 

 

 

</telerik:AjaxSetting>

 

 

 

 

 

 

  

 

<telerik:AjaxSetting AjaxControlID="Gridfungenericasoriginal">

 

 

 

 

 

 

<UpdatedControls>

 

 

 

 

 

 

<telerik:AjaxUpdatedControl ControlID="Gridfungenericasoriginal" />

 

 

 

 

 

 

<telerik:AjaxUpdatedControl ControlID="Gridfungenericascopia" />

 

 

 

 

 

 

</UpdatedControls>

 

 

 

 

 

 

</telerik:AjaxSetting>

 

 

 

 

 

 

<telerik:AjaxSetting AjaxControlID="Gridfungenericascopia">

 

 

 

 

 

 

<UpdatedControls>

 

 

 

 

 

 

<telerik:AjaxUpdatedControl ControlID="Gridfungenericascopia" />

 

 

 

 

 

 

<telerik:AjaxUpdatedControl ControlID="msggenericas" />

 

 

 

 

 

 

</UpdatedControls>

 

 

 

 

 

 

</telerik:AjaxSetting>

 

 

 

 

 

 

</AjaxSettings>

 

 

 

 

 

 

</telerik:RadAjaxManager>

 

 

 

 

 

 

<div>

 

 

 

 

 

 

 

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

 

 

 

 

 

 

<script type="text/javascript">

 

 

 

 

 

function ShowCatalogoGenericas()

 

{

window.radopen(

 

"Default4.aspx", "UserListDialog");

 

 

 

return false;

 

}

 

 

function refreshGrid(arg)

 

{

 

 

if(!arg)

 

{

$find(

 

"<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");

 

}

 

 

else

 

 

 

 

{

$find(

 

"<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");

 

}

}

 

 

</script>

 

 

 

 

 

 

</telerik:RadCodeBlock> &nbsp;

 

 

 

 

 

 

 

 

 

<telerik:RadWindowManager ID="RadWindowManager1" runat="server">

 

 

 

 

 

 

<Windows>

 

 

 

 

 

 

<telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Height="400px"

 

 

 

 

 

 

Width="300px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" />

 

 

 

 

 

 

</Windows>

 

 

 

 

 

 

</telerik:RadWindowManager>

 

 

 

 

 

<asp:Button ID="Button3" runat="server" Text="genericas" OnClientClick="return ShowCatalogoGenericas();" /><br />

 

 

 

 

 

 

 

<div>

 

 

 

 

 

 

<telerik:RadScriptBlock runat="server" ID="scriptBlockGenericas">

 

 

 

 

 

 

<script type="text/javascript">

 

 

 

 

<!--

 

 

function onRowDroppingGenericas(sender,args) {

 

 

 

if(sender.get_id()=="<%=Gridfungenericasoriginal.ClientID %>") {

 

 

 

var node=args.get_destinationHtmlElement();

 

 

 

if(!isChildOf('<%=Gridfungenericascopia.ClientID %>',node)&&!isChildOf('<%=Gridfungenericasoriginal.ClientID %>',node)) {

 

args.set_cancel(

 

true);

 

}

}

 

 

else {

 

 

 

var node=args.get_destinationHtmlElement();

 

 

 

if(!isChildOf('trashCanGenericas',node)) {

 

args.set_cancel(

 

true);

 

}

 

 

else {

 

 

 

if(confirm("┬┐Eliminar datos?"))

 

args.set_destinationHtmlElement($get(

 

'trashCanGenericas'));

 

 

 

else

 

 

 

 

args.set_cancel(

 

true);

 

}

}

}

 

 

function isChildOf(parentId,element) {

 

 

 

while(element) {

 

 

 

if(element.id&&element.id.indexOf(parentId)> -1) {

 

 

 

return true;

 

}

element=element.parentNode;

}

 

 

return false;

 

}

-->

 

 

</script>

 

 

 

 

 

 

</telerik:RadScriptBlock>

 

 

 

 

 

 

<div style="float:left; padding:0 6px 0 10px">

 

 

 

 

 

 

<telerik:RadGrid ID="Gridfungenericasoriginal" runat="server" AllowMultiRowSelection="True" AllowFilteringByColumn="True" Width="430px" Font-Bold="True" Font-Names="Tahoma" Font-Size="Small" OnNeedDataSource="Gridfungenericasoriginal_NeedDataSource" OnRowDrop="Gridfungenericasoriginal_RowDrop" OnColumnCreated="Gridfungenericasoriginal_ColumnCreated">

 

 

 

 

 

 

<MasterTableView DataKeyNames="clave_divis,clave_pues,clave_funcion_generica,grupo_orga" TableLayout="Fixed" NoMasterRecordsText="No hay datos para mostrar." Font-Bold="True" Font-Names="Tahoma" Font-Size="X-Small" CommandItemDisplay="Top">

 

 

 

 

 

 

<HeaderStyle Font-Bold="True" Font-Names="Tahoma" Font-Size="Small" />

 

 

 

 

 

 

<FooterStyle Font-Bold="True" Font-Names="Tahoma" Font-Size="Medium" />

 

 

 

 

 

 

<ItemStyle Font-Bold="True" Font-Names="Tahoma" Font-Size="X-Small" />

 

 

 

 

 

 

</MasterTableView>

 

 

 

 

 

 

<ClientSettings AllowRowsDragDrop="True">

 

 

 

 

 

 

<Selecting AllowRowSelect="True" EnableDragToSelectRows="False"/>

 

 

 

 

 

 

<ClientEvents OnRowDropping="onRowDroppingGenericas" />

 

 

 

 

 

 

<Scrolling AllowScroll="True" UseStaticHeaders="True"/>

 

 

 

 

 

 

<DataBinding FilterParameterType="String" SortParameterType="String">

 

 

 

 

 

 

</DataBinding>

 

 

 

 

 

 

</ClientSettings>

 

 

 

 

 

 

</telerik:RadGrid>

 

 

 

 

 

 

</div>

 

 

 

 

 

 

<br />

 

 

 

 

 

 

<div style="float:right; padding:0 10px 0 6px; font-weight: bolder; color: black;">

 

 

 

 

Para agregar funcion generica a este perfil arrastre elementos de la tabla izquierda.

 

<br />

 

 

 

 

 

 

<telerik:RadGrid ID="Gridfungenericascopia" runat="server" AllowMultiRowSelection="True" GridLines="None" Width="400px" OnNeedDataSource="Gridfungenericascopia_NeedDataSource" OnRowDrop="Gridfungenericascopia_RowDrop" OnColumnCreated="Gridfungenericascopia_ColumnCreated">

 

 

 

 

 

 

<MasterTableView DataKeyNames="clave_divis, clave_pues,clave_funcion_generica, grupo_orga" HeaderStyle-Font-Bold="true" HeaderStyle-Font-Names="Tahoma" HeaderStyle-Font-Size="Small" ItemStyle-Font-Bold="true" ItemStyle-Font-Names="Tahoma" ItemStyle-Font-Size="Small" Font-Bold="true" Font-Names="Tahoma" Font-Size="Small">

 

 

 

 

 

 

<NoRecordsTemplate>

 

 

 

 

 

 

<div style="height: 30px; cursor: pointer;">

 

 

 

 

No hay datos para mostrar

 

</div>

 

 

 

 

 

 

</NoRecordsTemplate>

 

 

 

 

 

 

<HeaderStyle Font-Bold="True" Font-Names="Tahoma" Font-Size="Small" />

 

 

 

 

 

 

</MasterTableView>

 

 

 

 

 

 

<ClientSettings AllowRowsDragDrop="True">

 

 

 

 

 

 

<Selecting AllowRowSelect="True" EnableDragToSelectRows="False" />

 

 

 

 

 

 

<ClientEvents OnRowDropping="onRowDroppingGenericas" />

 

 

 

 

 

 

<Scrolling AllowScroll="True" UseStaticHeaders="True" />

 

 

 

 

 

 

</ClientSettings>

 

 

 

 

 

 

</telerik:RadGrid>

 

 

 

 

 

 

</div>

 

 

 

 

 

 

<br />

 

 

 

 

 

 

<br />

 

 

 

 

 

 

<br />

 

 

 

 

 

 

 

<div style="clear: both;">

 

 

 

 

 

 

<!-- -->

 

 

 

 

 

 

</div>

 

 

 

 

 

 

<div class="exFooter">

 

 

 

 

 

 

<br />

 

 

 

 

 

 

<a id="trashCanGenericas" href="#" onclick="return false;">Papelera de reciclaje</a>

 

 

 

 

 

 

<div class="exMessage" runat="server" id="msggenericas" visible="false" enableviewstate="false">

 

 

 

 

Dato(s) eliminados con exito

 

 

</div>

 

 

 

 

 

 

</div>

 

 

 

 

 

 

</div>

 

 

 

 

 

 

</div>

 

 

 

 

protected

void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)

 

{

 

 

if (e.Argument == "Rebind")

 

{

Gridfungenericasoriginal.MasterTableView.SortExpressions.Clear();

Gridfungenericasoriginal.MasterTableView.GroupByExpressions.Clear();

Gridfungenericasoriginal.Rebind();

 

}

 

 

else if (e.Argument == "RebindAndNavigate")

 

{

Gridfungenericasoriginal.MasterTableView.SortExpressions.Clear();

Gridfungenericasoriginal.MasterTableView.GroupByExpressions.Clear();

Gridfungenericasoriginal.MasterTableView.CurrentPageIndex = Gridfungenericasoriginal.MasterTableView.PageCount - 1;

Gridfungenericasoriginal.Rebind();

 

}

}

 



And here is my RadWindow to edit Gridfungenericasoriginal (drag and drop)

 

<

 

script type="text/javascript">

 

 

 

 

 

 

function CloseAndRebind(args)

 

{

GetRadWindow().Close();

GetRadWindow().BrowserWindow.refreshGrid(args);

}

 

 

 

function GetRadWindow()

 

{

 

 

var oWindow = null;

 

 

 

if (window.radWindow) oWindow = window.radWindow;

 

 

 

 

 

 

else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;

 

 

 

 

 

 

 

return oWindow;

 

}

 

 

function CancelEdit()

 

{

GetRadWindow().Close();

}

 

 

</script>

 

 

 

 

 

 

 

<br />

 

 

 

 

 

 

<br />

 

 

 

 

 

 

<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticUpdates="True" AllowPaging="True"

 

 

 

 

 

 

AutoGenerateEditColumn="True" DataSourceID="SqlDataSource1" GridLines="None" OnItemUpdated="RadGrid1_ItemUpdated">

 

 

 

 

 

 

<MasterTableView AutoGenerateColumns="False" DataKeyNames="clave_divis,grupo_orga,clave_pues,clave_funcion_generica"

 

 

 

 

 

 

DataSourceID="SqlDataSource1">

 

 

 

 

 

 

<RowIndicatorColumn>

 

 

 

 

 

 

<HeaderStyle Width="20px" />

 

 

 

 

 

 

</RowIndicatorColumn>

 

 

 

 

 

 

<ExpandCollapseColumn>

 

 

 

 

 

 

<HeaderStyle Width="20px" />

 

 

 

 

 

 

</ExpandCollapseColumn>

 

 

 

 

 

 

<Columns>

 

 

 

 

 

 

<telerik:GridBoundColumn DataField="clave_divis" HeaderText="clave_divis" ReadOnly="True"

 

 

 

 

 

 

SortExpression="clave_divis" UniqueName="clave_divis">

 

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

 

<telerik:GridBoundColumn DataField="grupo_orga" DataType="System.Int32" HeaderText="grupo_orga"

 

 

 

 

 

 

ReadOnly="True" SortExpression="grupo_orga" UniqueName="grupo_orga">

 

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

 

<telerik:GridBoundColumn DataField="clave_pues" HeaderText="clave_pues" ReadOnly="True"

 

 

 

 

 

 

SortExpression="clave_pues" UniqueName="clave_pues">

 

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

 

<telerik:GridBoundColumn DataField="clave_funcion_generica" DataType="System.Int32"

 

 

 

 

 

 

HeaderText="clave_funcion_generica" ReadOnly="True" SortExpression="clave_funcion_generica"

 

 

 

 

 

 

UniqueName="clave_funcion_generica">

 

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

 

<telerik:GridBoundColumn DataField="puesto" HeaderText="puesto" SortExpression="puesto"

 

 

 

 

 

 

UniqueName="puesto">

 

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

 

<telerik:GridBoundColumn DataField="funcion_generica" HeaderText="funcion_generica"

 

 

 

 

 

 

SortExpression="funcion_generica" UniqueName="funcion_generica">

 

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

 

</Columns>

 

 

 

 

 

 

</MasterTableView>

 

 

 

 

 

 

</telerik:RadGrid><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:perfiles_dnConnectionString %>"

 

 

 

 

 

 

ProviderName="<%$ ConnectionStrings:perfiles_dnConnectionString.ProviderName %>"

 

 

 

 

 

 

SelectCommand="SELECT * FROM funciones_genericas" UpdateCommand="UPDATE funciones_genericas SET funcion_generica=@funcion_generica WHERE clave_divis=@clave_divis AND grupo_orga=@grupo_orga AND clave_pues=@clave_pues AND clave_funcion_generica=@clave_funcion_generica">

 

 

 

 

 

 

</asp:SqlDataSource>

 

 

 

 

protected

 

void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)

 

{

ClientScript.RegisterStartupScript(Page.GetType(),

 

"mykey", "CloseAndRebind();", true);

 

}

 

 

please help me.

Thanks in advance.

 

3 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 01 Apr 2010, 12:38 PM
Hi Omar,

I have reviewed the source code which you post, however it is not runnable and I could not reproduce the described issue. In order to achieve the desired functionality please check out the following online example which demonstrates how to use RadWindow for editing RadGrid records:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window

Best wishes,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rohan
Top achievements
Rank 1
answered on 20 Jun 2012, 11:29 AM
Hi all

I want drag and drop , paging and sorting of rad grid and the  rad grid present inside the radwindow  . Whenever i drag the column from the rad grid to group panel my rad grid is not getting refreshed data or grouping of selected column . how can i do this .........
0
Radoslav
Telerik team
answered on 25 Jun 2012, 07:22 AM
Hello Rohan,

I am sending you a simple example which demonstrates the desired functionality. Please check it out and let me know if it helps you.

Looking forward for your reply.

Regards,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
omar treviño
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Rohan
Top achievements
Rank 1
Share this question
or