My code is consist of the flowing parts: I think my problem is c# code i want to write something in the LoadGrid function , The CommandHandler is a function fire from update command column in gried panel.
<%--Ext.net code --%>
<%--this for create panel Accordion and put inside it 2 panel that contain the grout boxes --%>
<ext:Panel IDMode="Static" ID="panAccordion" runat="server" Title="مراسل صادر وارد"
AutoHeight="true" Height="400" BodyBorder="false" Icon="ApplicationTileVertical"
Layout="Accordion" Hidden="true" AutoShow="True" AutoWidth="True">
<LayoutConfig>
<ext:AccordionLayoutConfig Animate="true" />
</LayoutConfig>
<Items>
<ext:Panel IDMode="Static" ID="Paout" runat="server" Title="مراسل صادر" Collapsed="true"
AutoHeight="true">
<Items>
<ext:CheckboxGroup IDMode="Static" ID="cbgout" runat="server" ColumnsNumber="1" Hidden="true">
<Items>
<ext:Checkbox ID="cboutdef" runat="server" BoxLabel="lbcbout" Checked="true" />
</Items>
</ext:CheckboxGroup>
</Items>
</ext:Panel>
<ext:Panel ID="pain" runat="server" Title="مراسل وارد" Collapsed="true" AutoHeight="true">
<Items>
<ext:CheckboxGroup IDMode="Static" ID="cbgin" runat="server" ColumnsNumber="1" Hidden="true">
<Items>
<ext:Checkbox ID="cbindef" runat="server" BoxLabel="lbcbin" Checked="true" />
</Items>
</ext:CheckboxGroup>
</Items>
</ext:Panel>
//c# code to retrieve data
//--------------------------
[DirectMethod]
public string CommandHandler(string command, int EmpID)
{
try
{
if (command == "Delete")
{
Employees mc = new Employees();
mc = EmployeesDB.GetItem(EmpID);
// mc.MailCategory_ID = CategID;
mc.Employee_IsDeleted = true;
int x = EmployeesDB.Save(mc);
if (x > 0)
{
LoadGrid();
return "تمت عملية الحذف بنجاح";
}
else
{
return "يرجى المحاولة لاحقاً";
}
}
else if (command == "Edit")
{
string ID = (string)hidevalu.Value;
int tempx = Convert.ToInt32(ID);
Employees emp = new Employees();
emp = EmployeesDB.GetItem(tempx);
Hierarchy hier = new Hierarchy();
txtEMPNm.Text = emp.Employee_Name;
txtLogin.Text = emp.Employee_UserName;
// txtpass.Text = emp.Employee_Password;
txtMail.Text = emp.Employee_EmailAdress;
ddlPositin.SetValue(emp.Employee_Position);
cbMainEmp.Checked = Convert.ToBoolean(emp.Employee_IsFirstReciever);
cbCtsEmp.Checked = Convert.ToBoolean(emp.Employee_IsCTSEmployee);
int hrnodId = Convert.ToInt32(emp.Hierarchy_ID);
hier = HierarchyDB.GetItem(hrnodId);
txtMang.Text = hier.Hierarchy_Name.ToString();
///////////////////
hrnodId = Convert.ToInt32(emp.Hierarchy_SupervisorAtHierarchy_ID);
if (hrnodId != -1)
{
cbIS_supervis.Checked = true;
hier = HierarchyDB.GetItem(hrnodId);
txtSupervisior.Text = hier.Hierarchy_Name.ToString();
}
else {
cbIS_supervis.Checked = false;
txtSupervisior.Visible = false;
}
//////////////////
ddlRights.SetValue(emp.Group_ID);
//////////empCatalogprevaleg/////////
if (cbCtsEmp.Checked)
{
List<EmployeesCatigoriesPreveleges> empcp = EmployeesCatigoriesPrevelegesDB.GetList();
var empcplist = from empcatalogP in empcp
where empcatalogP.Employee_ID == tempx //&& o.Hierarchy_IsDeleted == false
select empcatalogP;
EmployeesCatigoriesPreveleges emcatprev = empcplist.ElementAt(0);
cbResIn.Checked = emcatprev.EmployeeCatigoriesPrevelege_HaveImportPrevelege.Value;
cbRespOut.Checked = emcatprev.EmployeeCatigoriesPrevelege_HaveExportPrevelege.Value;
cbResIn.RemoveListener("Check", "GetByCatigory");
cbRespOut.RemoveListener("Check", "GetByCatigory");
if (cbRespOut.Checked)
{
Paout.Enabled = true;
string ExpPriv = emcatprev.EmployeeCatigoriesPrevelege_ExportCatigoriesPrevelegs;
string[] elem = ExpPriv.Split(',');
Paout.ClearContent();
cbgout.Hidden = false;
panAccordion.Hidden = false;
Paout.Hidden = false;
panAccordion.Show();
//Paout.Expand();
cbgout.Items.RemoveAt(0);
LoadGrid(0, elem);
cbRespOut.AddListener("Check", "GetByCatigory");
}
if (cbResIn.Checked)
{
pain.Enabled = true;
string ExpPriv = emcatprev.EmployeeCatigoriesPrevelege_ImportCatigoriesPrevelegs;
string[] elem1 = ExpPriv.Split(',');
cbgin.Hidden = false;
panAccordion.Hidden = false;
pain.Hidden = false;
// pain.Expand();
pain.ClearContent();
cbgin.Items.RemoveAt(0);
LoadGrid(1, elem1);
cbResIn.AddListener("Check", "GetByCatigory");
}
//if (cbRespOut.Checked)
//{
// loadgrid(0, elem);
//}
//if (cbResIn.Checked)
//{
// loadgrid(1, elem);
//}
return "ok";
}
}
}
catch (Exception ex)
{
return ex.Message;
}
return "Unkown";
}
//------------------------------------------------------------------
private void LoadGrid(int value, string[] arr)
{
MailsCategories mailCat = new MailsCategories();
mailCat.Hierarchy_CategoryType = value;
List<MailsCategories> ms = MailsCategoriesDB.GetList(mailCat);
////////////////////////// ////////////////////////////////
int i = 0;
if (ms.Count() > 0)
{
//cbgout.Items.RemoveAt(0);
//cbgin.Items.RemoveAt(0);
foreach (MailsCategories mC in ms)
{
Ext.Net.Checkbox ck = new Ext.Net.Checkbox();
ck.AutoWidth = true;
// ck.BoxLabel = "مرحبا";//mC.MailCategory_Name;
ck.FieldLabel = mC.MailCategory_Name;
ck.Tag = mC.MailCategory_ID.ToString();
for (int tempcatval = 0; tempcatval < arr.Length; tempcatval++)
{
if (arr[tempcatval] == mC.MailCategory_ID.ToString())
{
ck.Checked = true;
ck.Value = true;
break;
}
}
//ck.Checked = Convert.ToBoolean(false);
ck.InputValue = "cbResout" + i;
ck.LabelAlign = Ext.Net.LabelAlign.Left;
if (value == 0)
{
cbgout.Items.Add(ck);
}
else
{
cbgin.Items.Add(ck);
}
i++;
}
if (value == 0)
{
cbgout.AddTo(this.Paout);
//cbgout.Render();
}
else
{
cbgin.AddTo(this.pain);
}
//stCategorymails.RefreshAfterSaving = Ext.Net.RefreshAfterSavingMode.Auto;
//stCategorymails.DataSource = li;
//stCategorymails.DataBind();
cbgout.Visible = true;
cbgin.Visible = true;
}
}
//----------------------------------------------------------this java script code send the comand from the ext.net page to C# page---------------------//
var loadingMsg = 'يرجى الانتظار جاري التحميل.....';
function CommandHandler(employeeForm, command, record) {
document.getElementById('hidevalu').value = record.data.Employee_ID;
document.getElementById('hfHairarcyIDsuper').value = record.data.Hierarchy_SupervisorAtHierarchy_ID;
var Empid = document.getElementById('hidevalu').value;
if (command == 'Edit') {
Ext.net.DirectMethods.CommandHandler(command, Empid);
// var form = employeeForm.getForm();
// form.items.items[0].setValue(record.data.Employee_Name);
// form.items.items[1].setValue(record.data.Employee_UserName);
// form.items.items[2].setValue(record.data.Employee_Password);
// form.items.items[4].setValue(record.data.Employee_EmailAdress);
// form.items.items[5].setValue(record.data.Employee_Position);
// form.items.items[6].setValue(record.data.Employee_IsFirstReciever);
// form.items.items[8].setValue(record.data.Employee_IsCTSEmployee);
// form.items.items[8].setValue(record.data.Group_ID);
// form.items.items[9].setValue(record.data.Hierarchy_ID);
// document.getElementById('hidevalu').value = record.data.Employee_ID;
document.getElementById('HFupdat').value = -1;
}
else {
Ext.Msg.confirm('حذف', 'هل انت متأكد من حذف المجموعة "' +
record.data.Employee_Name + '" ?', function (btn) {
if (btn == 'yes') {
Ext.net.DirectMethods.CommandHandler(command, record.data.Employee_ID, { success: function (result) {
Ext.Msg.show({
icon: Ext.MessageBox.INFO, msg: result, buttons: Ext.Msg.OK
})
},
eventMask: {
showMask: true, msg: loadingMsg
}
});
employeeForm.reset();
}
else {
return;
}
});
}
}