how to operate one row

35 views
Skip to first unread message

kismilan

unread,
Jun 29, 2009, 4:05:38 AM6/29/09
to Flexigrid for jQuery
I use flexigrid, it's so cool!

But where can i find it's document?

I even can't find what options it has? Is there a full document about
it?

A detailed question:

how i operate one row? I want to trigger an event when a row selected,
and how to get the value of selected row?

AcidRaZor

unread,
Jun 30, 2009, 9:34:03 AM6/30/09
to Flexigrid for jQuery
process:

there's a lot of examples out there. Right - Click and View source

rasensio

unread,
Jul 28, 2009, 9:17:27 AM7/28/09
to Flexigrid for jQuery
AcidRazor, this is a help forum, would be nice if you help and do not
blame pleople.

Kismilan, I would like to get the selected row and remove the selected
row, but I also can't find an example of that.
if you find something please let me know.
Regards
R

Dmitry Balchugov

unread,
Jul 28, 2009, 10:08:05 AM7/28/09
to flex...@googlegroups.com
Hello. Maybe my sample helps.

<javascript>
var hMyLister = $("#flexigrid2").flexigrid({
url: '/?',
dataType: 'json',
colModel : [
{display: 'ID', name : 'id', width :
25, sortable : true, align: 'center'},
{display: 'caption', name : 'caption', width
: 200, sortable : true, align: 'left'},
{display: 'url', name : 'url', width : 200,
sortable : true, align: 'left'},
{display: 'enabled.', name : 'enabled', width :
25, sortable : true, align: 'left'},
{display: 'edit', name : 'ctled', width
: 25, sortable : false, align: 'center', process:edRow},
{display: 'delete', name : 'ctldl',
width : 25, sortable : false, align: 'center', process:delRow}
],

sortname: "caption",
sortorder: "asc",
usepager: false,
title: 'records',
useRp: false,
rp: 2000,
showTableToggleBtn: false,
width: 'auto',
height: 320,
autoload: false
});

function delRow(celDiv,id){
$(celDiv).click(function(){
var r=confirm('Do you want to delete record '+id+'?');
if( r ) {
/* deleting record here
id -- id of row (see first column)
celDiv -- id of div-block, contains cell data
*/
hMyLister.flexReload();

}
});
};

function edRow(celDiv,id){
$(celDiv).click(function(){
/* editing record here */
hMyLister.flexReload();
});
};

</javascript>

My flex has two buttons in each line (at the end columns): 'edit' & 'delete'.

bill sion

unread,
Jul 28, 2009, 10:16:23 PM7/28/09
to flex...@googlegroups.com
<script type="text/javascript">

            $("#grid").flexigrid
            (
            {
            url: "<?php echo url('shippings/JsonData')?>",
            dataType: 'json',
            colModel : [
                {display: '编号', name : 'id', width : 40, sortable : true, align: 'center'},
                {display: '标题', name : 'title', width : 160, sortable : true, align: 'left'},
                {display: '船型', name : 'ship_type', width: 90, sortable : true, align: 'left'},
                {display: '起始港', name : 'set', width : 80, sortable : true, align: 'left'},
                {display: '目的港', name : 'end', width : 80, sortable : true, align: 'left'},
                {display: '船公司', name : 'company', width : 100, sortable : true, align: 'right'},
                {display: '添加时间', name : 'created', width : 120, sortable : true, align: 'right'}
                ],
            searchitems : [
                {display: '标题', name : 'title'},
                {display: '船公司', name : 'company', isdefault: true}
                ],
            buttons : [
                {name: '添加', bclass: 'add', onpress : test},
                {separator: true},
                {name: '修改', bclass: 'edit', onpress : test},
                {separator: true},
                {name: '删除', bclass: 'delete', onpress : test},
                {separator: true}
                ],
            sortname: "id",
            sortorder: "desc",
            usepager: true,
            title: '船运报价列表',
            useRp: true,
            rp: 30,
            showTableToggleBtn: true,
            width: 760,
            rpOptions: [10,15,20,25,40],
            onSubmit: addFormData,
            height: 737
            }
            );

function test(com,grid)
{
    switch(com)
    {
        case '添加':location.href='<?php echo url("shippings/create")?>';break;
        case '修改':
                    selected_count = $('.trSelected', grid).length;
                    if(selected_count == 0){
                        alert('请选择一条记录', '系统提示');
                        return false;
                    }

                    if(selected_count > 1){
                        alert('抱歉,每次只能修改一条记录', '系统提示');
                        return false;
                    }
                    location.href='<?php echo url("shippings/edit")?>' + '/id/' + $('.trSelected td:nth-child(1) div', grid).text();
        ;break;
        case '删除':
                    selected_count = $('.trSelected', grid).length;
                    if(selected_count == 0){
                        alert('请选择一条记录', '消息提示');
                        return false;
                    }

                    if(selected_count > 1){
                        alert('抱歉,每次只能删除一条记录', '消息提示');
                        return false;
                    }
                    name = $('.trSelected td:nth-child(2) div', grid).text();
                    id = $('.trSelected td:nth-child(1) div', grid).text();
                    if(confirm("确定要删除标题为[" + name + "]的信息?")){
                        delRow(id);
                    }
        ;break;
    }       
}

   

function addFormData()
    {
   
    var dt = $('#sform').serializeArray();
    $("#grid").flexOptions({params: dt});
    return true;
    }
   
$('#sform').submit
(
    function ()
        {
            $('#grid').flexOptions({newp: 1}).flexReload();
            return false;
        }
);

function delRow(id){
    $.ajax({
        url: '<?php echo url("shippings/delete")?>',
        data:{
            id: id
        },
        type: 'POST',
            dataType: 'json',
        success:function(){
                $('#grid').flexReload();
            }
    });
}
</script>
here is my script for your reference.

--
yours

ssal...@gmail.com

unread,
Aug 23, 2009, 10:12:33 AM8/23/09
to Flexigrid for jQuery
This is a hack drawn from a couple examples others posted here but it
does want I want: triggers a call to a javascript function when you
click on a row. The only problem I have is that the rows I have
clicked stay "highlighted".

How to "unselect" a row?

1) add "process:selRow" to your column definitions
{display: 'ID', name : 'id', width : 40, sortable : true,
align: 'left', process:selRow},

2) javascript function that is triggered when you click a row

function selRow(celDiv,id)
{
$(celDiv).click(function(){
alert(id);
});

AcidRaZor

unread,
Sep 22, 2009, 6:27:08 AM9/22/09
to Flexigrid for jQuery
Hi rasensio.

His question was answered by me. Both times. First, his question was
"how do I get the value of a selected row"

I told him how. Via the process: command. All he needed to do is
google that within this group and get tons of replies on how to.

Then, on his question to where to find documentation, I told him, the
best way is to view the source of what others have done.

How is this NOT helping?

Or just because I didn't give him a detailed explanation and sample
code (doing the programming FOR him) and pointed him in the right
direction to teach him how to use his natural (I assume) ability he
has to find information, process it and apply it.... TEACHING him more
about the component rather than doing the work for him, is "not
helping"

n00b

On Jul 28, 3:17 pm, rasensio <rasen...@gmail.com> wrote:
> AcidRazor, this is a help forum, would be nice if you help and do not
> blame pleople.
>
> Kismilan, I would like togettheselectedrowand remove theselectedrow, but I also can't find an example of that.
> if you find something please let me know.
> Regards
> R
>
> On Jun 29, 5:05 am, kismilan <qih...@gmail.com> wrote:
>
> > I use flexigrid, it's so  cool!
>
> > But where can i find it's document?
>
> > I even can't find what options it has? Is there a full document about
> > it?
>
> > A detailed question:
>
> > how i operate onerow? I want to trigger an event when arowselected,
Reply all
Reply to author
Forward
0 new messages