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
Hi
I have integrated WebCombo in WebGrid.
For a better usability, i want set the default value of WebCombo. The default value should be the previous value that the user has chosen. The frist time the default value is empty.
Some tips, how i can do this?
Thanks
Michael
Hi Michael,
I don't suggest you to use that way. If you don't want to define the index manually (data[i]), it would be better if you are using the workaround below.
rowChange.Row.Cells.GetNamedItem("SupplierID").Text
Hope this helps.
Regards,Handy
Normally, when you integrate WebCombo into WebGrid, the default value or text should be fit with WebGrid cell value text. I don't quite understand about what your requirement. But If you want to set default value of WebCombo, you can set WebCombo1.Value at page load server side.Or if you want to set text of WebGridRow (WebCombo depend on this value), you need to specify at OnInitilizeRow event. Hope this helps.
Regards,HAndy
Hi Handy
I want to do the following:
When a user adds a new row, I want cache the new cell values. If the user adds an another row, i want to use the cached cell values as default values. Maybe can i use Cookies?
With batch update the client side events OnAfterAdd/OnBeforeAdd are not fired!
Which event do I need?
Serverside or Clientside?
Regards
I think use Input Text hidden is better than using cookies. It also easier to use.
When you at BatchUpdate scenario, those events would not be fired. It is a default behaviour. The correct event you should be looking for, is OnAddPendingChanges client side event.
Thanks for your last post!
I use OnAddPendingChanges to store rowdata in hidden input text:
document.getElementById("Hidden1").value = rowChange.Data[1].NewValue;
document.getElementById("Hidden2").value = rowChange.Data[1].NewText;
document.getElementById("Hidden3").value = rowChange.Data[2].NewValue;
and so on...
For reading from hidden input text i use OnRowSelect:
if (rowEl.getAttribute("type") == "NewRow") {
But how can i restore?
}
I try this:
rowEl.cells[4].innerHTML = document.getElementById("Hidden1").value;
or this:
var newRow = grd.RootTable.NewRow(); var cells = newRow.GetCells();
cells.GetNamedItem("Column1").SetValue(document.getElementById("Hidden1").value, false); cells.GetNamedItem("Column1").SetText(document.getElementById("Hidden2").value, false); cells.GetNamedItem("Column2").SetValue(document.getElementById("Hidden3").value, false);
Which is the best way to do this?
Thanks for a sample.
Best regards
Handy is not present today and I’m here to help him to provide you a solution for your scenario.
I’d like to propose another solution for your scenario. There is a property called “DefaultValue” in WebGridColumn that specify the default value of the column when new row is added. We can take the advantage of this property to set the default value of WebCombo (as edit type of the column) in new row of WebGrid.
I enclosed one simple sample to be tested on your end. In the sample, WebGrid is bind to table “Products” of Northwind database where the columns are: [ProductID]; [ProductName]; [SupplierID]; and [CategoryID]. Value list is added into [SupplierID] and [CategoryID] column in order to have WebGrid shows [CompanyName] and [CategoryName] respectively. Two WebCombos are also added as the edit type of [SupplierID] and [CategoryID] column.
I simply create two global variables to store cached new cells value. These values are initially set with no value (empty). On AddPendingChanges event, the cached new cells value is stored into the global variable and then set the “DefaultValue” of [SupplierID] and [CategoryID] column with the stored values.
<script type="text/javascript"> <!-- var Supplier; var Category; function WebGrid1_OnAddPendingChanges(controlId, table, rowChange) { var WebGrid1 = ISGetObject(controlId); //store added pending changes of Supplier and Categories Supplier = rowChange.Data[2].NewText; Category = rowChange.Data[3].NewText; //set default value of SupplierID and CategoryID column WebGrid1.RootTable.Columns.GetNamedItem("SupplierID").DefaultValue = Supplier; WebGrid1.RootTable.Columns.GetNamedItem("CategoryID").DefaultValue = Category; return true; } --> </script>
For more detail information, please check the attached sample.
Hope this help.
Only one word: great!
I still have a shorter version.
Because I use SystemID and ComputerID with ValueList, I need to save default text and default value. Now it works fine!!!
<script language="javascript" type="text/javascript" id="grd_OnAddPendingChanges"> <!-- function grd_OnAddPendingChanges(controlId, table, rowChange) { var grd = ISGetObject(controlId); grd.RootTable.Columns.GetNamedItem("ComputerID").DefaultValue = rowChange.Data[1].NewValue; grd.RootTable.Columns.GetNamedItem("ComputerID").DefaultText = rowChange.Data[1].NewText; grd.RootTable.Columns.GetNamedItem("SystemID").DefaultValue = rowChange.Data[2].NewValue; grd.RootTable.Columns.GetNamedItem("SystemID").DefaultText = rowChange.Data[2].NewText; grd.RootTable.Columns.GetNamedItem("Name").DefaultValue = rowChange.Data[3].NewValue; return true; } --> </script>
Great job, Yudi!
Thanks a lot.
Hi Yudi
Why doesn't this not work:
Supplier = rowChange.Data[rowChange.Row.Cells.IndexOf(SupplierID)].NewText;
IndexOf() get always -1!
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