Welcome Guest Search | Active Topics | Sign In | Register

Samples Options
?????????
Posted: Sunday, April 22, 2012 3:18:25 PM
Rank: Newbie
Groups: Member

Joined: 4/22/2012
Posts: 7
Hi

I'm new programmer and i have never worked with tools before in VS , Yesterday i spent a lot of time trying to figure out how to work with the eo.Grid and damn how bad i found my self at programming XD

So moment ago i completely gave up and i want some help :(

I looked up the samples but it's only a demo that show me how it will looks like and not how to code it, Also i searched the forums and Googled it and i found nothing :(

#1
The things i want is, To select a row from a grid and from it's cells i want to fill the textboxes that i have placed in the page
I tried the ItemCommand sample
Code: Visual Basic.NET
Protected Sub Grid1_ItemCommand(sender As Object, e As EO.Web.GridCommandEventArgs)
        If e.CommandName = "select" Then
            Dim s As String = String.Empty
            s += "Row Index:" + e.Item.Index.ToString()
            s += "<br />Posted At:" + e.Item.Cells(1).Value.ToString()
            s += "<br />Posted By:" + e.Item.Cells(2).Value.ToString()
            s += "<br />Topic:" + e.Item.Cells(3).Value.ToString()
            lblInfo.Text = s
        End If
    End Sub

But the event didn't trigger, I have putted the grid in a callbackpanel and changed the properties of RunningMode to callback, Is there something else i should do ?

#2
I also wanted to delete a row from a grid and i know that it only delete from a client side and not from the database, But how do handle it after i delete couple of rows ?
I have searched and learned from other topics and this is what got to
Code: Visual Basic.NET
Protected Sub Grid1_ItemDeleted(sender As Object, e As EO.Web.GridItemEventArgs) Handles Grid1.ItemDeleted
        Dim con As SqlConnection = New SqlConnection(WebConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString)
        For i = 0 To Grid1.RecordCount - 1
            If Grid1.Items(i).Deleted Then
                Dim cmd As New SqlCommand("Delete from tblClinic where ID=" & Grid1.Items(i).Cells(3).Value & "", con)
                con.Open()
                cmd.ExecuteReader()
                con.Close()
            End If
        Next
End Sub

But it delete all the rows and not the one that are deleted from the grid
And i noticed that it triggered after any post-back happen like pressing a button, Is there a way to trigger after i delete single row immediately?

#3
And last the update row i have no idea how to do it :(

I know i'm asking a lot but i don't know what else to do, I hope there's someone who's kind enough to spare me some of his valuable time to help me out with this one.
And sorry for my poor English :(
Thanks.
eo_support
Posted: Sunday, April 22, 2012 4:04:48 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You are actually quite close. As to your questions:

#1. Check the following:
1. Whether you have the Grid's RunningMode set to Server;
2. The column that you wish to trigger the event must be a ButtonColumn;

#2. You can do the same as #1 ---- setting the Grid's RunningMode to Server and use a ButtonColumn to do the delete. However the fact that all rows are deleted shouldn't have anything to do with the Grid. Either they are really deleted in your database, in which case you will need to check your DB related code; Or they are not actually deleted from your database but are just cleared from the Grid, in which case you will need to check whether you have some code that actually cleared the Grid;

#3. You would handle ItemChanged event in order to handle update.

Thanks!
?????????
Posted: Sunday, April 22, 2012 6:33:39 PM
Rank: Newbie
Groups: Member

Joined: 4/22/2012
Posts: 7
Awesome it totally worked :D, My mistake was not using ButtonColumn

What about these event (ItemDeleted, ItemChanged) can they trigger immediately after their column deleted/changed ? if not then the best way is to put a commit button for user to click right ?

I did as you said about using #1 method with the delete and worked wonderfully, It delete as i click :)
But the update how can i make it work using the same method ? can you please post a sample code
or post sample code using ItemChanged Event

Thanks for your post it really helped me a lot :D
Looking forward for your replay.
eo_support
Posted: Sunday, April 22, 2012 8:15:10 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

If you want the Grid to immediately post back when an item is deleted, the easiest way is use steps in #1.

If you want to the Grid to immediately post back when an item is changed, then it will depends on the value of FullRowMode.

If FullRowMode is true, then you would handle the Grid's ClientSideAfterEditItem, then trigger a post back (see remark below) inside your handler. It will be something like this:

Code: HTML/ASPX
<eo:Grid ClientSideAfterEditItem="after_edit_item" ....>
....
</eo:Grid>


Code: JavaScript
function after_edit_item(gridItem, save)
{
    if (!save)
        return;

    setTimeout(function()
    {
        //trigger post back
        .....
    }, 10);
}


If you are familiar with how to trigger a post back from JavaScript code, you can use whatever code you are familiar with ---- this part doesn't really have much to do with the Grid at all. If you are not familiar with how to trigger a post back from JavaScript code, you can take a look of our ScriptEvent control:

http://www.essentialobjects.com/doc/1/eo.web.scriptevent.aspx

That is a free control that specifically designed for the purpose of trigering post back from JavaScript. All associated server side event will be triggered when the page posts back. For example, in this case, the Grid's ItemChanged event will be triggered.

If your Grid's FullRowMode is set to false, then you will need to handle the GridColumn's ClientSideEndEdit instead of the Grid's ClientSideAfterEditItem. That way every time you change a cell the Grid will post back ----- obviously this is not recommended since posting back too frequently can be very annoying for a lot of users.

Hope this helps. Please feel free to let us know if you still have any questions.

Thanks!
?????????
Posted: Monday, April 23, 2012 3:06:58 PM
Rank: Newbie
Groups: Member

Joined: 4/22/2012
Posts: 7
It worked :D,
Thanks to you i just purchased this tool and setting it to my website atm :)

But one last thing if i may :p, It's about adding new row to the grid
I did as the sample said and turn AllowNewItem = True, And there were a new row at the end of the grid but i couldn't enter any text in it, I also changed the column to Textbox, Also i tried with datasource control and without still can't enter anything, Any suggestion ?

Thanks
eo_support
Posted: Monday, April 23, 2012 3:29:32 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Check whether you have FullRowMode set to true or false; If you have FullRowMode set to true, then you MUST provide a way to put the whole row into edit mode. This is usually done by including a EditCommandColumn, however it can also be triggered by explicitly calling this function:

http://www.essentialobjects.com/doc/1/jsdoc.public.grid.edititem.aspx

If FullRowMode is set to false, then the cell should automatically enter edit mode on mouse click.

Thanks!


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.