0
votes

I am using Struts 2.3.7, struts2-jquery-grid-plugin-3.5.0.

<sjg:grid
    id="gridtable"
    caption="Issue-Summary"
    dataType="json"
    href="%{remoteurl}"
    pager="true"
    gridModel="finalGridModel"
    rowList="10,15,20"
    rowNum="15"
    rownumbers="true"   
>
    <sjg:gridColumn name="issue_id"  id="issueId"  index="id" title="Issue-ID" formatter="integer"  sortable="false"/>
    <sjg:gridColumn name="issue_description" index="issue_description" title="Issue-Details"  sortable="false"/>
    <sjg:gridColumn name="issue_raised_date" index="issue_raised_date" title="Issue-Date"  formatter="date"  sortable="false"/>

    <sjg:gridColumn  name="Details" title="Action"  formatter="formatLink" sortable="false"/>
    <sjg:gridColumn name="issue_status"  index="issue_status" title="Current Status"  sortable="false"/>
    <sjg:gridColumn name="assigned_to"  index="issue_status" title="Assigned To"  sortable="false"/>
</sjg:grid>

Here either I want to disable the specific row or a column i.e. Details after jqgrid is loaded. This column is a link to perform some operation. Disabling of rows are based on the issue_status. If current_status is "Assigned" then this row is disabled otherwise enabled. How to achieve this as I am a newbie so i expect some good solution form you guys. Also I have added a screenshots. enter image description here

Updated : these are the generated html when jqgrid executes.

<table class="ui-jqgrid-htable" cellspacing="0" cellpadding="0" border="0" aria-labelledby="gbox_gridtable" role="grid" style="width: 925px;">
<thead>
<tr class="ui-jqgrid-labels" role="rowheader">
<th id="gridtable_rn" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 25px;">
<div id="jqgh_gridtable_rn">
<span class="s-ico" style="display:none">
<span class="ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr" sort="asc"></span>
<span class="ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr" sort="desc"></span>
</span>
</div>
</th>
<th id="gridtable_issue_id" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
<th id="gridtable_issue_description" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
<th id="gridtable_issue_raised_date" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
<th id="gridtable_" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
<th id="gridtable_issue_status" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
<th id="gridtable_assigned_to" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
</tr>
</thead>
</table>
</div>
</div> 
2

2 Answers

0
votes

jqgrid have aftersavecell event.. By using it you can call a method when ever the value set to grid... Inside the method you can check your condition and set properties to your grid...

0
votes

i had a somewhat similar kind of scenario which i achieved by powerful DOM manipulation of jQuery.

i used a webGrid of MVC which actually renders as a table inside html and i have to apply some logic from the value of its one column.

first of all check what type of html element this grid generate when it executed. if it generates a table then this might be helpful for you,

    $('table#grid').ready(function () {
        MatchColumnValue(5);     //Select column node to match value from..starts from 0!
    });

here is the function.

function MatchColumnValue(nodeValue) {
    $('table#grid tr').each(function () {
        $(this).find('td:nth-child(' + nodeValue + '):contains(Assigned)').parent().attr('disabled', true);
    });
}