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
Hello,
I have a drop-down list outside the webgrid. The webgrid has two columns -
a) Decision (edittype = dropdownlist)
b) Checkbox Column
Scenario: The users want to check multiple check boxes in the grid, then use the drop-down list (which is outside the webgrid) to make a selection, click on a button next to the drop-down.
Expectation : The Decision column will show the value selected from the dropdown. And refreshes the data in the webgrid.
What is happening : The data is updated at the back-end in the database, but the grid is not showing the refreshed data. On rt clicking + Refresh, the new data is shown.
What I want - Is there a way to refresh the webgrid on the button click event once the data is written back to the database? I tried WebGrid1.ClientAction.Refresh in btn_Click event but its not refreshing the grid. i also tried WebGrid1.ClientAction.InvokeScript("ISGetObject('" + WebGrid1.ClientID + "').Refresh();") but it doesnt work.
Hello,Thank you for the question and I apologize for the inconvenience.I’ve made a simple sample that maybe similar with your current scenario. I bind the WebGrid to Northwind.mdb database and Shippers table.In my sample, you could update CompanyName column’s value, based on WebCombo’s value.I use SetText() method to update the selected row's cells (CompanyName) value.And I use Update() method to update the selected row object.I also set PersistRowChecker property of WebGrid to “True”. This makes the row checker is not being cleared during postback.Here’s the example java script code how to update selected row in WebGrid:
var i = 0;var intervalObj; function WebButton1_OnClientClick(controlId, parameter) { var WebButton1 = ISGetObject(controlId); var WebCombo1 = ISGetObject("WebCombo1"); var WebGrid1 = ISGetObject("WebGrid1"); var comboValue = WebCombo1.Value; // Get WebCombo Value var checkedRows = WebGrid1.RootTable.GetCheckedRows(); if (checkedRows.length > 0) { intervalObj = setInterval(function () { if (!WebGrid1.IsInProgress) { if (i < checkedRows.length) { var checkedRow = WebGrid1.RootTable.GetCheckedRows()[i]; var selectedRow = WebGrid1.RootTable.ToRowObject(checkedRow); var cells = selectedRow.GetCells(); if (selectedRow.KeyValue != '') { // update the selected row's cells value cells.GetNamedItem("CompanyName").SetText(comboValue, true); // update the selected row object selectedRow.Update(); } i++; } if (i >= checkedRows.length) { clearInterval(intervalObj); intervalObj = null; i = 0; } } }, 5); } return true; }
Please have a review on my sample as well and let me hear your response.Thank you.Regards,Hans.
Hans,
Thanks for the code. I have made some changes to the code and it works fine (except for one small issue that I am facing).
function saveDecision() { var grid = ISGetObject("WebGrid1"); var ddl = document.getElementById("<%= ddlDecision.ClientID %>"); var checkedRows = grid.RootTable.GetCheckedRows(); var ddlValue = ddl.options[ddl.selectedIndex].value; if (checkedRows.length > 0) { if (!grid.IsInProgress) { for (i = 0; i < checkedRows.length; i++) { var checkedRow = grid.RootTable.GetCheckedRows()[i]; var selectedRow = grid.RootTable.ToRowObject(checkedRow); var cells = selectedRow.GetCells(); if (selectedRow.KeyValue != '') { // update the selected row's cells value cells.GetNamedItem("Decision").SetText(ddlValue, true); // update the selected row object selectedRow.Update(); } } if (i >= checkedRows.length) { i = 0; } } } return true; }
I have removed the setInterval function from the code. I am not sure why do we need it. Please let me know what is the purpose of this function.
Also, though it is working fine, I am finding that a pop-up window opens in the grid that states "Are you sure you want to navigate away from the page?....." <attachment - error.jpg>
Please let me know how to take this out?
Thanks Hans! I was able to solve the issue. I have used your code and made PromptUnsavedChanges="false" to make it work.
Is there a way to change the Batch Update settings property at run time in javascript? Please let me know.
btw, I am marking your solution as the correct approach. It works absolutely grt! :) Thanks for the solution.
-Udayan
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