Jun 29, 2014, 6:30 PM
[CLOSED] Editable gridpanel with summery and celledit plugin and remote data
I do a design like this
VIEW CODE
CONROLLER CODE
VIEW CODE
@using Ext.Net
@using Ext.Net.MVC
@{
var X = Html.X();
}
<!DOCTYPE html>
<html>
<head>
<title>Ext.Net.MVC v2 Example</title>
<script>
var addPlant = function () {
var r = Ext.create('pr', {
//common: 'New Plant 1',
//light: 'Mostly Shady',
//price: 0,
//availability: Ext.Date.clearTime(new Date()),
//indoor: false
}),
grid = App.gridpanel;
grid.store.insert(0, r);
grid.editingPlugin.startEditByPosition({ row: 0, column: 0 });
};
var departmentRenderer = function (value) {
var r = App.scategory.getById(value);
if (Ext.isEmpty(r)) {
return "";
}
return r.data.Name;
};
</script>
</head>
<body>
@X.ResourceManager()
@(X.Store(
X.Store()
.Data(ViewBag.loadcategory)
.ID("scategory")
.Model(
X.Model()
.Fields(
Html.X().ModelField().Name("categoryid").Type(ModelFieldType.Int),
Html.X().ModelField().Name("categoryName").Type(ModelFieldType.String)
)
)
)
)
@(X.GridPanel()
.ID("gridpanel")
.Listeners(l =>
{
l.ViewReady.Fn = "addPlant";
l.ViewReady.Delay = 1;
})
.Store(Html.X().Store()
.Model(Html.X().Model()
.Name("pr")
//.IDProperty("ID")
.Fields(
new ModelField("griddatamaterialID", ModelFieldType.Int),
new ModelField("griddatacategoryid", ModelFieldType.Int),
new ModelField("griddataunitid", ModelFieldType.Int),
new ModelField("griddataquantity", ModelFieldType.Int),
new ModelField("griddataexpectedamount", ModelFieldType.Int)
)
)
// .DataSource(ViewBag.loadgrid)
)
.ColumnModel(
X.Column()
.Text("categoryName")
.DataIndex("griddatacategoryid")
//.Renderer("departmentRenderer")
.Editor(
X.ComboBox()
.DataIndex("categoryid")
.StoreID("scategory")
.TypeAhead(true)
.SelectOnTab(true)
.ValueField("categoryid")
.DisplayField("categoryName")
),
X.Column()
.Text("material")
.DataIndex("griddatamaterialID")
.Editor(
X.ComboBox()
.DataIndex("materialID")
.TypeAhead(true)
.SelectOnTab(true)
.ValueField("materialID")
.DisplayField("materialIDName")
.Data( ViewBag.loadcategory)
),
X.Column()
.Text("unit")
.DataIndex("griddataunitid")
.Editor(
X.ComboBox()
.DataIndex("unitid")
.TypeAhead(true)
.SelectOnTab(true)
.ValueField("unitid")
.DisplayField("unitName")
.Data( ViewBag.loadcategory)
),
X.Column()
.Text("Unit Price")
.Editor(
X.TextField()),
X.Column()
.Text("Quantity")
.DataIndex("griddataquantity")
.Editor(X.TextField()),
X.Column()
.DataIndex("griddataexpectedamount")
.Text("Expected Price")
.Editor(X.TextField())
)
.Plugins(X.CellEditing()
// .Listeners(events =>
// events.Edit.Handler = @"if (e.field === 'test') {
// e.record.set('test2', e.value);
// }"
// )
)
)
</body>
</html>
CONROLLER CODE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace ERP_test.Controllers
{
public class masterdetailsController : Controller
{
//
// GET: /masterdetails/
public ActionResult Index()
{
//ViewBag.loadcategory = category.categoryGetAll().Cast<object>().ToArray();
ViewBag.loadcategory = category.categoryGetAll();
//ViewBag.loadgrid = griddata.griddataGetAll();
return View();
}
}
}
public class griddata
{
public int griddatamaterialID { get; set; }
public int griddatacategoryid { get; set; }
public int griddataunitid { get; set; }
public int griddataquantity { get; set; }
public int griddataexpectedamount { get; set; }
public static List<griddata> griddataGetAll()
{
return new List<griddata>
{
new griddata {griddatamaterialID = 0,griddatacategoryid=0,griddataunitid=0, griddataquantity = 0,griddataexpectedamount=0},
};
}
}
public class material
{
public int materialID { get; set; }
public string code { get; set; }
public string materialIDName { get; set; }
public int unitid { get; set; }
public int categoryid { get; set; }
public static List<material> materialGetAll()
{
return new List<material>
{
new material {materialID = 1,code="m001", materialIDName = "material A",unitid=1,categoryid=1},
new material {materialID = 2, code="m002",materialIDName = "material B",unitid=1,categoryid=1},
new material {materialID = 3, code="m003",materialIDName = "material C",unitid=2,categoryid=2}
};
}
}
public class unit
{
public int unitid { get; set; }
public string unitName { get; set; }
public static List<unit> unitGetAll()
{
return new List<unit>
{
new unit { unitid=1,unitName = "unit A"},
new unit { unitid=2,unitName = "unit B"},
};
}
}
public class category
{
public int categoryid { get; set; }
public string categoryName { get; set; }
public static List<category> categoryGetAll()
{
return new List<category>
{
new category { categoryid=1,categoryName = "category A"},
new category { categoryid=2,categoryName = "category B"},
};
}
}
I need on first time all category load to category combo,after select a category material combo will fill.then after selecting material unit price and unit will fill.then i put quantity .then expected price calculate (UnitPrice*Quantity) and summery expected price will be show.I will not found any example of this scenario,so please help me and provide me some code sample to complete this.
Last edited by Daniil; Jun 30, 2014 at 11:40 AM.
Reason: [CLOSED]