|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
It's a typo. Should be eo_TriggerServerEvent. Sorry!
|
|
Rank: Advanced Member Groups: Member
Joined: 8/26/2009 Posts: 64
|
No problem.
Hey -- before I launch into the EXCELLENT sample code you provided ... are you sure I need it?
I just tested my code again -- and have it showing what it is seeing in Grid1.ChangedItems in a panel -- and honestly, it seems to be working perfectly without the slightest lag -- maybe an extra update statement here/there but that's fine.
When you say it can't be "relied on" -- are you sure? What do you mean by that? I can't make it fail. Here's my VB so you can see I am seeing what it is seeing with every cell change. (I got this loop from your sample code.)
Protected Sub ScriptEvent1_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Handles ScriptEvent1.Command Dim vName As String Dim vDocID As Int64 Dim s As String = String.Empty If Grid1.ChangedItems.Length = 0 Then s += "No item has changed." Else Dim item As GridItem For Each item In Grid1.ChangedItems Dim cell As GridCell For Each cell In item.Cells
If cell.Modified Then vName = cell.Value vDocID = item.Key SqlDataSource1.UpdateCommand = "UPDATE [Documents] SET [Name] = '" & vName & " ' WHERE [DocID] = " & vDocID.ToString SqlDataSource1.Update() Dim [text] As String = String.Format("Cell Changed: Key = {0}, Field = {1}, New Value = {2}", item.Key, cell.Column.DataField, cell.Value)
s += "<br />" s += [text] End If Next cell Next item End If
'Response.Write(s) Dim info As New Literal() info.Text = s Panel1.Controls.Add(info) End Sub
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
It's great to see you got all parts working together. When we say it can't be relied on, we meant that it may contain items that have already been updated, which would probably cause "an extra update statement here/there", but it should be no big deal as long as users are not modifying 1000 rows/second.
|
|
Rank: Advanced Member Groups: Member
Joined: 8/26/2009 Posts: 64
|
OK, that wouldn't be an issue in my case (ever), but I can see how it would be an issue. I also think the SQLDataSource control has a built-in way around it. I'll try your code too as it's cleaner/tighter. Very good then, you win the "Best Support for Noobie Award" for today. I'll try to post a "walk-through" style summary when I get it all done. AND, barring anything that blows up or something -- I will, for certain, license your product. Great sales job.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Great to hear that we got another award! :)
Let us know if there is anything else.
|
|
Rank: Advanced Member Groups: Member
Joined: 8/26/2009 Posts: 64
|
function on_endedit(cell, newValue) { var oldval = cell.getValue() if (oldval != newValue) { setTimeout(function() { eo_TriggerServerEvent("<%=ScriptEvent1.ClientID%>", "whatever", "anything"); }, 10); } return newValue }
I did this instead of the global var method you kindly provided above. It only raises the server event if the cell data has changed, therefore, I only ever have one item in Grid.ChangedItems and only ever do one update -- seemed easier to code and it appears to work flawlessly. Anything wrong with the idea?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Yes. I believe this will work well too.
|
|