EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jega on April 05, 2018, 03:57:56 AM



Title: Propertygrid
Post by: jega on April 05, 2018, 03:57:56 AM
Hi.

Can't see the solution.

Have this propertygrid

<table id="pg" class="easyui-propertygrid" style="width:300px" data-options="
data:[{'ID':'unitaddress','name':'Address','value':'Yes','group':'unit','editor':{'type':'checkbox','options':{'on':'Yes','off':'No'}}}]">
</table>


Saving the propertygrid checkbox state to database. On site ready, if unitAddress is false, the value must be set to "No" and checkbox must be unchecked


Jesper


Title: Re: Propertygrid
Post by: jarry on April 05, 2018, 08:20:15 AM
Listen to the 'onEndEdit' event, detect if the checkbox is checked and do more actions according to your requirement.
Code:
$('#pg').propertygrid({
onEndEdit: function(index,row){
if (row.name == 'Address'){
var ed = $(this).propertygrid('getEditors',index)[0];
if ($(ed.target).is(':checked')){
//...
} else {
//...
}
}
}
})


Title: Re: Propertygrid
Post by: jega on April 05, 2018, 11:32:02 AM
Hi Jarry

Thanks for answer.

BUT. this was not what i was looking for. Or.

What i have is

<table id="pg" class="easyui-propertygrid" style="width:300px" data-options="
data:[{'ID':'unitaddress','name':'Address','value':'Yes','group':'unit','editor':{'type':'checkbox','options':{'on':'Yes','off':'No'}}}]">
</table>


   $( document ).ready(function(){
      if (QueryString.get('designid') != ''){
         getDesignData(QueryString.get('designid'));
      }
      
   });

Function getDesigndata is a call to the MySQL db which returns this json data

{
    "ID": "1",
    "designName": "Testdesign 1",
    "designData": [{
        "unitaddress": "false"
    }],
    "editedBy": "user",
    "editedTimestamp": "05-04-2018 16:30:18"
}

Now i loop through designData (have more than unitaddress) and want to have the propertygrid row, with id=unitaddress, value = "No" and the checkbox be unchecked.

So i want to set the rows value and editors checkbox

Have i explained it good enough ??


Jesper


Title: Re: Propertygrid
Post by: jarry on April 06, 2018, 06:54:36 AM
You can call 'updateRow' method to update the special row.
Code:
var index = ...  // find the row index you want to update
pg.propertygrid('updateRow', {
index: index,
row: {
value: 'No'
}
});