Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
rowattr triger after setRowData
17/04/2014
17:29
Avatar
jan-kratochvil
Member
Members
Forum Posts: 8
Member Since:
17/04/2014
sp_UserOfflineSmall Offline

I'm using rowattr to format data and it works fine, but when a change data in a row with setRowData I need to reformat the row with rowattr taking account new data set. Is it possible to trigger this update somehow?

Thank you Jan

19/04/2014
11:57
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

You can try to use setColProp  to change the rowattr function before to use setRowData.

This can be something like this:

// this is the new rowattr function

function newrowattrset(..)

{

...

}

...

$("#grid").jqGrid('setColProp', 'mycolname', {rowattr: newrowattrset});

$("#grid").jqGrid('setRowData',....);

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

28/04/2014
17:55
Avatar
jan-kratochvil
Member
Members
Forum Posts: 8
Member Since:
17/04/2014
sp_UserOfflineSmall Offline

Sorry for the delay, but this is not the solution.

I don't know if my question is clear, but I need to update row attribues according to new value set with setRowData, thank you.

29/04/2014
12:21
Avatar
jan-kratochvil
Member
Members
Forum Posts: 8
Member Since:
17/04/2014
sp_UserOfflineSmall Offline

If I load data with ajax, rowattr gets applied correctly, but when I dynamicly change data with setRowData teh formatting doesn't change.

03/05/2014
10:12
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Can you please show us with code how you do this. The code with ajax and the dynamic code too?

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

03/05/2014
22:24
Avatar
jan-kratochvil
Member
Members
Forum Posts: 8
Member Since:
17/04/2014
sp_UserOfflineSmall Offline

My grid (this works fine):

<script language="javascript">
jQuery('#objednavky').jqGrid({
    hoverrows:false,
    gridview:true,
    scrollPaging:true,
    rowNum:100,
    rowList:[20,50,100,500],
    sortname:'doklad',
    sortorder:'desc',
    toolbarfilter: true,
    url: {link loadGrid!},
    datatype:'json',
    colNames:[ 'Doklad','Objednávka','Datum','IÄŒO','Zákazník','Kód','Plat','Splat','Suma','Suma s DPH','Potvrz','Dod','Odsouhlaseno'],
    colModel :[
      { name:'doklad', index:'doklad', width:120, align:'left'},
      { name:'objednavka', index:'objednavka', width:70, align:'left'},
      { name:'dat_por', index:'dat_por', width:80, align:'left'},
      { name:'ico', index:'ico', width:70, align:'left'},
      { name:'zkraceny_nazev', index:'zkraceny_nazev', width:170, align:'left'},
      { name:'zakazka', index:'zakazka', width:40},
      { name:'typ_uhrady', index:'typ_uhrady', width:40},
      { name:'splatnost', index:'splatnost', width:40},
      { name:'cena_bez_dph', index:'cena_bez_dph', width:80, formatter:currencyFormatter},
      { name:'cena_celkem', index:'cena_celkem', width:80, formatter:currencyFormatter},
      { name:'potvrzeno', index:'potvrzeno', width:40},
      { name:'dodano', index:'dodano', width:40},
      { name:'odsouhlaseno', index:'odsouhlaseno', width:40, hidden:true},
    ],
    rowattr: function (rd) {
      if ((rd.dodano == "Ne") && (rd.potvrzeno == "Ano")) {
        return {"style": "background-color:#FFFF99;"};
      }
      if (rd.dodano == "ÄŒást") {
        return {"style": "background-color:#CCFF99;"};
      }
      if (rd.dodano == "Ano") {
        return {"style": "background-color:#99FF66;"};
      }
    }
});
</script>

Now tha data change code (button code):

    $.ajax({ url:'\/objednavky\/?do=potvrd&doklad='+id })
     .done(function(d) {
            $('#objednavky').jqGrid('setRowData',id, d.rowData );
     });

This callback changes potvrzeno to "Ano", but the rowattr formatter doesn't reformat it...

Is is now clear, what is the problem?

04/05/2014
10:48
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Yes - it is clear now. Thanks for posting the code.

rowattr event fire only when a new row is inserted, but not when it is updated.

The event will fire when you use addRowData.

To do what you want you will need set the attribute of the row using jQuery.

Kind Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

05/05/2014
09:36
Avatar
jan-kratochvil
Member
Members
Forum Posts: 8
Member Since:
17/04/2014
sp_UserOfflineSmall Offline

Thank you, can you please hint me, what is the easiest way to address the TR element of the exact row?

06/05/2014
09:59
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

If you know the id of the row and the grid id then you can

$("#rowId","#gridId").css("property","value");

Kind regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

06/05/2014
15:52
Avatar
jan-kratochvil
Member
Members
Forum Posts: 8
Member Since:
17/04/2014
sp_UserOfflineSmall Offline

Thank you for your help, I did it this way, if someone is interested...

<script language="javascript">
function rowStyle(rd) {
      if ((rd.dodano == "Ne") && (rd.potvrzeno == "Ano")) { // verify that the testing is correct in your case
        return {"style": "background-color:#FFFF99;"};
      }
      if (rd.dodano == "ÄŒást") { // verify that the testing is correct in your case
        return {"style": "background-color:#CCFF99;"};
      }
      if (rd.dodano == "Ano") { // verify that the testing is correct in your case
        return {"style": "background-color:#99FF66;"};
      }
      return {"style": ""};
}
 
function objednavkyPotvrd(grid,id){
    $.ajax({ url:'\/objednavky\/?do=potvrd&doklad='+id })
     .done(function(d) {
            //set columns returned by ajax call
            $('#'+grid).jqGrid('setRowData',id, d.rowData );
            //get the whole row
            var rd = $('#'+grid).jqGrid ('getRowData', id);  
            //set the row css
            $('#'+id).attr(rowStyle(rd));
     });
}

jQuery('#objednavky').jqGrid({
    hoverrows:false,
    gridview:true,
    scrollPaging:true,
    rowNum:100,
    rowList:[20,50,100,500],
    sortname:'doklad',
    sortorder:'desc',
    toolbarfilter: true,
    url: {link loadGrid!},
    datatype:'json',
    colNames:[ 'Doklad','Objednávka','Datum','IÄŒO','Zákazník','Kód','Plat','Splat','Suma','Suma s DPH','Potvrz','Dod','Odsouhlaseno'],
    colModel :[
      { name:'doklad', index:'doklad', width:120, align:'left'},
      { name:'objednavka', index:'objednavka', width:70, align:'left'},
      { name:'dat_por', index:'dat_por', width:80, align:'left'},
      { name:'ico', index:'ico', width:70, align:'left'},
      { name:'zkraceny_nazev', index:'zkraceny_nazev', width:170, align:'left'},
      { name:'zakazka', index:'zakazka', width:40},
      { name:'typ_uhrady', index:'typ_uhrady', width:40},
      { name:'splatnost', index:'splatnost', width:40},
      { name:'cena_bez_dph', index:'cena_bez_dph', width:80, formatter:currencyFormatter},
      { name:'cena_celkem', index:'cena_celkem', width:80, formatter:currencyFormatter},
      { name:'potvrzeno', index:'potvrzeno', width:40},
      { name:'dodano', index:'dodano', width:40},
      { name:'odsouhlaseno', index:'odsouhlaseno', width:40, hidden:true},
    ],
    rowattr: function (rd) {
      return rowStyle(rd);
    },
});

06/05/2014
15:52
Avatar
jan-kratochvil
Member
Members
Forum Posts: 8
Member Since:
17/04/2014
sp_UserOfflineSmall Offline

...

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
24 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information