EasyUI Forum
May 17, 2024, 11:54:10 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Simple implementation of Row Editing in DataGrid  (Read 4955 times)
ltpitt
Newbie
*
Posts: 6


View Profile Email
« on: March 03, 2014, 03:26:51 PM »

Hi everybody Smiley

I am struggling on this example:

http://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=default&dir=ltr&pitem=  

(To see what I talk about you need to select "Row Editing in DataGrid" on the left)

It looks like a simple datagrid loading data from json and a nice combobox loading data from a different json.

They work together nicely.

I've simply tried to do the same on my webserver:

http://pitto.dyndns.org/icompass/test.html

The thing won't work: initial data is not loaded in the combobox.
If I simply click so modify it then I see data in it.

I've just copied the example: what am I doing wrong?
« Last Edit: March 03, 2014, 03:33:00 PM by ltpitt » Logged
Andy1980
Newbie
*
Posts: 14


View Profile Email
« Reply #1 on: March 04, 2014, 04:17:55 AM »

sorry can't open your link,
but u should do the following like in examples:


Code:
  for the content of your combobox:

var products = [
    {productid:'FI-SW-01',name:'Koi'},
    {productid:'K9-DL-01',name:'Dalmation'},
    {productid:'RP-SN-01',name:'Rattlesnake'},
    {productid:'RP-LI-02',name:'Iguana'},
    {productid:'FL-DSH-01',name:'Manx'},
    {productid:'FL-DLH-02',name:'Persian'},
    {productid:'AV-CB-01',name:'Amazon Parrot'}
];

Code:
  for defining the datagrid.

$(function(){
$('#tt').datagrid({
title:'Editable DataGrid',
iconCls:'icon-edit',
width:660,
height:250,
singleSelect:true,
idField:'itemid',
url:'data/datagrid_data.json',
columns:[[
{field:'itemid',title:'Item ID',width:60},
{field:'productid',title:'Product',width:100,
formatter:function(value){
for(var i=0; i<products.length; i++){
if (products[i].productid == value) return products[i].name;
}
return value;
},
editor:{
type:'combobox',
options:{
valueField:'productid',
textField:'name',
data:products,
required:true
}
}
}, .....



as you can see it uses the products json as data for the combo.
This works fine with me.

you find the example right here: http://www.jeasyui.com/tutorial/datagrid/datagrid12.php
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!