Welcome Guest Search | Active Topics | Sign In | Register

eo_Callback and eo_TriggerScriptEvent with ClientSideEndEdit handler Options
eo_support
Posted: Thursday, August 27, 2009 8:49:21 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
It's a typo. Should be eo_TriggerServerEvent. Sorry!
pghcpa
Posted: Thursday, August 27, 2009 9:03:33 PM
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
eo_support
Posted: Thursday, August 27, 2009 9:11:16 PM
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.
pghcpa
Posted: Thursday, August 27, 2009 9:17:35 PM
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.Angel

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.
eo_support
Posted: Thursday, August 27, 2009 9:23:11 PM
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.
pghcpa
Posted: Friday, August 28, 2009 4:57:59 AM
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?
eo_support
Posted: Friday, August 28, 2009 9:04:30 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Yes. I believe this will work well too.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.