with extjs grid(with combobox)使用嵌套对象选择,保存和删除数据

时间:2017-03-31 18:45:35

标签: javascript extjs combobox extjs6 extjs6-classic

例如,我有以下两个对象:

对象1:

{

Id: 1,

Name: 'Menu 1',

MenuSuper: null

}

对象2:

{

Id: 2,
Name: 'Menu 2',
MenuSuper: { 
   Id: 1 
}

}

如何操作网格来保存,删除和选择这个? 我的问题是'MenuSuper'。如何在网格编辑器中使用带有组合框的嵌套对象?

1 个答案:

答案 0 :(得分:0)

对不起我的延误。

这是小提琴: https://fiddle.sencha.com/#view/editor&fiddle/1tk3

但我已经解决了这个问题。

当我把一个组合框作为"编辑"在列中,我还为它设置了渲染。

例如:

import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions, Response } from '@angular/http';
import { Observable } from 'rxjs';
import 'rxjs/add/operator/map';

import { AuthenticationService } from './index';
import { Post } from '../_models/index';

@Injectable()
export class PostService {
    constructor( private http: Http, private authenticationService: AuthenticationService) {}

    getPosts(): Observable<Post[]> {
        // add authorization header with jwt token
        let headers = new Headers();
        headers.append('Authorization','token ' + this.authenticationService.token);

          headers.append('Content-Type', 'application/json');
          let options = new RequestOptions({
              headers: headers
          });  //  console.log(headers);

        // get posts from api
        return this.http.get('http://localhost:8000/areas/fun/', options)
        .map((response: Response) => response.json());
    }
}

在这段代码中,我没有检查&#34;值&#34;是null,这是我的错!必须按以下方式检查此部分:

 renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {     
                var combo = this.columns[colIndex].getEditor();
                var combostore = combo.getStore();              
                var dataIndex = combostore.findExact('id', value);
                var recordCombo = combostore.getAt(dataIndex);              
                return recordCombo.get('name');
            },  

解决方案非常简单! THX!