hi,
i want to add a new row to the grid at the client side using a javascript code and not losing the data i inserted when i postback to the server. here is a code snippet,
ASPX
<dnn:DNNGrid
id="grdDestinations" AutoGenerateColumns="false" CssClass="dnnGrid dnnSecurityRolesGrid"
Runat="server" AllowPaging="True" EnableViewState="False" PageSize="10">
<MasterTableView CommandItemDisplay="Top" DataKeyNames="ComRuleItemID">
<CommandItemTemplate>
<table><tr><td width="30%">
<asp:HyperLink ID="cmdAddDestination" runat="server" CausesValidation="False" />
when clicking on this hyperlink my custom javascript method AddNewDestination() will be called
</td></tr></table>
</CommandItemTemplate>
<Columns>
<dnn:DnnGridTemplateColumn UniqueName="ComRuleActions" >
<ItemTemplate>
<dnn:DnnImageButton runat="server" ID="Delete" CommandName="Delete" IconKey="Delete" />
<asp:HiddenField ID="DestinationGroupID" runat="server" />
</ItemTemplate>
</dnn:DnnGridTemplateColumn>
<dnn:DnnGridBoundColumn datafield="DestinationName" headertext="Destination" HeaderStyle-Width="95%"/>
</Columns>
</MasterTableView>
<PagerStyle Mode="NumericPages" Position="Bottom"></PagerStyle>
<ClientSettings EnablePostBackOnRowClick="true">
</ClientSettings>
</dnn:DNNGrid>
JavaScript
function AddNewDestination() {
var newDestinationValue = 'This value i will get by my self from somewher';
var masterTable = $find("<%= grdDestinations.ClientID %>").get_masterTableView();
masterTable.insertItem(newDestinationValue);
}
C#
protected void grdDestinations_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "PerformInsert")
{
//Do here my server side insertion process in grid
}
}
My Problem is:
1) in order to make the event grdDestinations_ItemCommand fired by calling the javascript method masterTable.insertItem(newDestinationValue) i had to set the grdDestinations.MasterTableView.IsItemInserted = true;
and this property when sitting with true, an unwanted insertion form appeared above the grid, so how i can remove this form and keeps the event firing....?
2)how can i get the data i inserted by calling the javascript masterTable.insertItem(newDestinationValue) ,in the server side is the data is passed to the server so i will be able to handle it in server side....???
3)i know that there is something wrong , if iam using the feature in a wrong way feel free to tell the right way even if i have to delete all my work.
4) thank you very much in advance.....:)))
i want to add a new row to the grid at the client side using a javascript code and not losing the data i inserted when i postback to the server. here is a code snippet,
ASPX
<dnn:DNNGrid
id="grdDestinations" AutoGenerateColumns="false" CssClass="dnnGrid dnnSecurityRolesGrid"
Runat="server" AllowPaging="True" EnableViewState="False" PageSize="10">
<MasterTableView CommandItemDisplay="Top" DataKeyNames="ComRuleItemID">
<CommandItemTemplate>
<table><tr><td width="30%">
<asp:HyperLink ID="cmdAddDestination" runat="server" CausesValidation="False" />
when clicking on this hyperlink my custom javascript method AddNewDestination() will be called
</td></tr></table>
</CommandItemTemplate>
<Columns>
<dnn:DnnGridTemplateColumn UniqueName="ComRuleActions" >
<ItemTemplate>
<dnn:DnnImageButton runat="server" ID="Delete" CommandName="Delete" IconKey="Delete" />
<asp:HiddenField ID="DestinationGroupID" runat="server" />
</ItemTemplate>
</dnn:DnnGridTemplateColumn>
<dnn:DnnGridBoundColumn datafield="DestinationName" headertext="Destination" HeaderStyle-Width="95%"/>
</Columns>
</MasterTableView>
<PagerStyle Mode="NumericPages" Position="Bottom"></PagerStyle>
<ClientSettings EnablePostBackOnRowClick="true">
</ClientSettings>
</dnn:DNNGrid>
JavaScript
function AddNewDestination() {
var newDestinationValue = 'This value i will get by my self from somewher';
var masterTable = $find("<%= grdDestinations.ClientID %>").get_masterTableView();
masterTable.insertItem(newDestinationValue);
}
C#
protected void grdDestinations_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "PerformInsert")
{
//Do here my server side insertion process in grid
}
}
My Problem is:
1) in order to make the event grdDestinations_ItemCommand fired by calling the javascript method masterTable.insertItem(newDestinationValue) i had to set the grdDestinations.MasterTableView.IsItemInserted = true;
and this property when sitting with true, an unwanted insertion form appeared above the grid, so how i can remove this form and keeps the event firing....?
2)how can i get the data i inserted by calling the javascript masterTable.insertItem(newDestinationValue) ,in the server side is the data is passed to the server so i will be able to handle it in server side....???
3)i know that there is something wrong , if iam using the feature in a wrong way feel free to tell the right way even if i have to delete all my work.
4) thank you very much in advance.....:)))