iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I have a dropdownlist on the form and the selected value controls the edit mode of the webgrid on a flypostback action. I call webgrid.RefreshAll on list changes the selection. On event _webGrid_InitializeLayout, set the AllowAddNew, AllowEdit, AllowDelete based on the list selection. When they are all set to false, you got a client error when you tries to edit a cell, you can even delete a row. You still got the Add New Row, Edit, Delete option on the context menu. The layoutsetting does not work correctly on a flypostback.
The attached is a working sample. Please check TestLayoutForm and try selecting 2008.
Is this a bug? Please advise me how to make it work properly.
Thanks,
Yuting
You will need to set the property in the client side to disable editing and deleting completely. In order to achieve that, you will need to invoke JS function in InitializeLayout server side event. Here is the updated code snippet. For InitializeLayout server side event:
protected void _webGrid_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e){ short fiscalYear = short.Parse(_fiscalYearList.SelectedValue); if (fiscalYear == 2009) { e.Layout.AllowAddNew = AddNew.Yes; e.Layout.AllowEdit = Edit.Yes; e.Layout.AllowDelete = Delete.Yes; _webGrid.ClientAction.InvokeScript("setWebGridAccess('write')"); } else { e.Layout.AllowAddNew = AddNew.No; e.Layout.AllowEdit = Edit.No; e.Layout.AllowDelete = Delete.No; _webGrid.ClientAction.InvokeScript("setWebGridAccess('read')"); }}
Added JS function:
function setWebGridAccess(type) { var wg = ISGetObject('_webGrid'); if (type == "read") { wg.RootTable.AllowEdit = "no"; wg.RootTable.AllowDelete = "no"; wg.RootTable.AllowAddNew = "no"; } else { wg.RootTable.AllowEdit = "yes"; wg.RootTable.AllowDelete = "yes"; wg.RootTable.AllowAddNew = "yes"; }}
You are right about disable editing and deleting in the client side but not for enable them. If I invoke JS function in InitializeLayout server side event to enable them, they will be disabled. So I have to remove the invoke script line, and then it is working. Here is the updated code snippet.
How come enable editing/deleting doesn't have to set in the client side but disable does?
Thanks!
protected void _webGrid_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e) { short fiscalYear = short.Parse(_fiscalYearList.SelectedValue); if (fiscalYear == 2009) { e.Layout.AllowAddNew = AddNew.Yes; e.Layout.AllowEdit = Edit.Yes; e.Layout.AllowDelete = Delete.Yes; //comment out this line, will make it to work. //_webGrid.ClientAction.InvokeScript("setWebGridAccess('write')"); } else { e.Layout.AllowAddNew = AddNew.No; e.Layout.AllowEdit = Edit.No; e.Layout.AllowDelete = Delete.No; _webGrid.ClientAction.InvokeScript("setWebGridAccess('read')"); } }
function setWebGridAccess(type) { var wg = ISGetObject('_webGrid'); if (type == "read") { wg.RootTable.AllowEdit = "No"; wg.RootTable.AllowDelete = "No"; wg.RootTable.AllowAddNew = "No"; } else { wg.RootTable.AllowEdit = "Yes"; wg.RootTable.AllowDelete = "Yes"; wg.RootTable.AllowAddNew = "Yes"; } }
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname