- Home
- Forum
- ASP.NET Web Forms
- Selected grid details add to another grid
Selected grid details add to another grid
If I click product grid button (select button) ,selected product details can add to material grid ?
Thanks
Pratheep
Attachment: WebApplication1_427ce8c2.rar
| <ej:Grid ID="ProductGrid" ClientIDMode="Static" runat="server" AllowPaging="True" AllowFiltering="false" OnServerEditRow="EditEvents_ServerEditRow" OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow"> <ClientSideEvents ActionComplete="complete" RowSelected="selected" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit" /> ... <script type="text/javascript"> ... function selected(args) { var data = $('#<%= ProductGrid.ClientID %>').ejGrid("instance")._dataSource(); var grid = $('#<%= ProductGrid.ClientID %>').ejGrid("instance"); var record = args.data.Productcode; var detaildata = ej.DataManager(data).executeLocal(ej.Query().where("Productcode", ej.FilterOperators.equal, record, false)); var gridObj = $('#<%= MaterialGrid.ClientID %>').ejGrid("instance"); gridObj.dataSource(ej.DataManager(detaildata)); } </script> |
Thank you for your support.Working fine
Thanks
Pratheep
last selected product code only showing MaterialGrid.earlier selected codes not showing
example
product code
0001
0002
0003
if I select 0001 that will appear at Material Grid after that I select 0002 than 0002 only showing at MaterialGrid
Can I get all select product codes show at Material Grid (0001,0002)
It's possible without select ProductGrid row , client side button (Product Grid button ) click event add product code to MaterialGrid
<ej:Column HeaderText=" " Template="true" TemplateID="#buttonTemplate" TextAlign="Center" Width="75" AllowFiltering="false"/>
$(function () {
$(".Details").ejButton({
click: function (e) {
},
});
}
Thanks
Pratheep
| $(function () { $(".Details").ejButton({ click: function (e) { var obj = $('#<%= ProductGrid.ClientID %>').data("ejGrid"); var record = obj.getSelectedRecords(); var gridObj = $('#<%= MaterialGrid.ClientID %>').ejGrid("instance"); if (gridObj.model.dataSource == null) gridObj.dataSource(record); else { gridObj.model.dataSource.push(record[0]); //push the dataSource object to the grid. gridObj.refreshContent(); } }) |
Thank you for your help.Its working fine
Thanks
Pratheep
Product Grid unable to update Type / delete the records
after product details add to material grid unable to update material code, material name / delete the material records
Thanks
Pratheep
Attachment: WebApplication1_68d1d438.rar
after product details add to material grid unable to update material code, material name / delete the material records
Thanks
Pratheep
Attachment: WebApplication1_fc7ccd17.rar
|
<ej:Grid ID="ProductGrid" ClientIDMode="Static" runat="server" AllowPaging="True" AllowFiltering="false" OnServerEditRow="EditEvents_ServerEditRow"
OnServerAddRow="EditEvents_ServerAddRow" OnServerDeleteRow="EditEvents_ServerDeleteRow">
<ClientSideEvents ActionComplete="complete" EndAdd="endAdd" EndDelete="endDelete" EndEdit="endEdit" DataBound="databound" />
...
function databound(args){
$(".Details").ejButton({
click: function (e) {
...
}
});
} |
|
<script type="text/template" id="materialtemplate">
...
<input id="Materialcode" name="Materialcode" value="{{: Materialcode}}"
...
<input id="Materialname" name="Materialname" value="{{:Materialname}}" class="e-field e-ejinputtext valid"
...
</table>
</script> |
|
protected void EditActionMaterial(string eventType, object record)
{
List<Materials> data = Session["MaterialDataSource"] as List<Materials>; //update the material grid records after selecting from client side.
Dictionary<string, object> KeyVal = record as Dictionary<string, object>;
if (eventType == "endEdit")
{
Materials value = new Materials();
foreach (KeyValuePair<string, object> keyval in KeyVal)
{
if (keyval.Key == "Materialcode")
{
...
}
}
}
Session["MaterialDataSource"] = data;
this.MaterialGrid.DataSource = data;
this.MaterialGrid.DataBind();
}
[Serializable]
public class Materials
{
public Materials()
{
}
public Materials(int Materialcode, string Materialname, int Productcode, string Productname)
{
this.Materialcode = Materialcode;
this.Materialname = Materialname;
this.Productname = Productname;
this.Productcode = Productcode;
}
public int Materialcode { get; set; }
public string Materialname { get; set; }
public int Productcode { get; set; }
public string Productname { get; set; }
} |
Thank you for your support
Cant update Material Grid
List<Materials> data = Session["MaterialDataSource"] as List<Materials>;
// empty selected Product code
if (eventType == "endEdit")
{
Materials value = new Materials();
foreach (KeyValuePair<string, object> keyval in KeyVal)
{
if (keyval.Key == "Productcode")
{
value = data.Where(d => d.Productcode == (int)keyval.Value).FirstOrDefault();
value.Productcode = Convert.ToInt32(keyval.Value);
}
else if (keyval.Key == "Materialname")
value.Materialname = Convert.ToString(keyval.Value);
else if (keyval.Key == "Materialcode")
value.Materialcode = Convert.ToInt16(keyval.Value);
}
Thanks
Pratheep
Attachment: WebApplication1_3d6aeed8.rar
| <asp:HiddenField ID="SelectRecords" ClientIDMode="Static" runat="server" /> <script type="text/javascript"> function OnCreate(args) { $(".Details").ejButton({ click: function (e) { var obj = $('#<%= ProductGrid.ClientID %>').data("ejGrid"); var record = obj.getSelectedRecords(); var gridObj = $('#<%= MaterialGrid.ClientID %>').ejGrid("instance"); $("#SelectRecords").val(JSON.stringify(record)); if (gridObj.model.dataSource == null) gridObj.dataSource(record); else { gridObj.model.dataSource.push(record[0]); gridObj.refreshContent(); } } }); } </script> protected void EditActionMaterial(string eventType, object record) { JavaScriptSerializer ser = new JavaScriptSerializer(); //get currentView List<Materials> sel = ser.Deserialize<List<Materials>>(this.SelectRecords.Value); . . . .. . Session["MaterialDataSource"] = data; this.MaterialGrid.DataSource = data; this.MaterialGrid.DataBind(); } |
- 12 Replies
- 3 Participants
-
PR Pratheep
- Jan 29, 2017 03:42 AM UTC
- Feb 16, 2017 12:58 PM UTC