Kendo网格数据没有绑定

时间:2015-08-23 21:17:23

标签: asp.net-mvc kendo-ui kendo-grid kendo-asp.net-mvc

我试图用来自SQL的数据绑定一个Kendo Grid。该表出现但未填充任何数据。我无法弄清楚出了什么问题。我感谢所有的帮助!

这是我的控制器:

>>> import jsonrpclib, json
>>> from nltk.parse import DependencyGraph
>>>
>>> server = jsonrpclib.Server("http://localhost:8080")
>>> parses = json.loads(
...    server.parse(
...       'John loves Mary. '
...       'I saw a man with a telescope. '
...       'Ballmer has been vocal in the past warning that Linux is a threat to Microsoft.'
...    )
... )['sentences']
>>>
>>> def transform(sentence):
...     for rel, _, head, word, n in sentence['dependencies']:
...         n = int(n)
...
...         word_info = sentence['words'][n - 1][1]
...         tag = word_info['PartOfSpeech']
...         lemma = word_info['Lemma']
...         if rel == 'root':
...             # NLTK expects that the root relation is labelled as ROOT!
...             rel = 'ROOT'
...
...         # Hack: Return values we don't know as '_'.
...         #       Also, consider tag and ctag to be equal.
...         # n is used to sort words as they appear in the sentence.
...         yield n, '_', word, lemma, tag, tag, '_', head, rel, '_', '_'
...
>>> dgs = [
...     DependencyGraph(
...         ' '.join(items)  # NLTK expects an iterable of strings...
...         for n, *items in sorted(transform(parse))
...     )
...     for parse in parses
... ]
>>>
>>> # Play around with the information we've got.
>>>
>>> pprint(list(dgs[0].triples()))
[(('loves', 'VBZ'), 'nsubj', ('John', 'NNP')),
 (('loves', 'VBZ'), 'dobj', ('Mary', 'NNP')),
 (('loves', 'VBZ'), 'punct', ('.', '.'))]
>>>
>>> print(dgs[1].tree())
(saw I (man a (with (telescope a))) .)
>>>
>>> print(dgs[2].to_conll(4))  # doctest: +NORMALIZE_WHITESPACE
Ballmer     NNP     4       nsubj
has         VBZ     4       aux
been        VBN     4       cop
vocal       JJ      0       ROOT
in          IN      4       prep
the         DT      8       det
past        JJ      8       amod
warning     NN      5       pobj
that        WDT     13      dobj
Linux       NNP     13      nsubj
is          VBZ     13      cop
a           DT      13      det
threat      NN      8       rcmod
to          TO      13      prep
Microsoft   NNP     14      pobj
.           .       4       punct
<BLANKLINE>

这是我的ViewModel:

public ActionResult Test()
{
    return View();
}

[HttpGet]
public ActionResult Test_Read([DataSourceRequest] DataSourceRequest request)
{
    return Json(GetCountries().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

[NonAction]
private IQueryable<CountryViewModel> GetCountries()
{
    return from user in database.Countries
           select new CountryViewModel
           {
               Id = user.Id,
               Name = user.Name,
           };
}

这是实体模型数据向导自动生成的模型:

public class CountryViewModel
{
    public int Id { get; set; }
    public string Name { get; set; }
}

这是视图:

public partial class Country
{
    public Country()
    {
        this.Cities = new HashSet<City>();
        this.Regions = new HashSet<Region>();
    }

    public int Id { get; set; }
    public string Name { get; set; }
    public System.DateTime CreatedDate { get; set; }

    public virtual ICollection<City> Cities { get; set; }
    public virtual ICollection<Region> Regions { get; set; }
}

1 个答案:

答案 0 :(得分:0)

In view page,
if you are having a button:
<a href="javascript:void(0)" onclick="insert()"><button> Insert </button>
<script>
function insert(){
     name = $('#tagname').val();
     var img = $('#imgtag').find( 'img' );
     var id = $( img ).attr( 'id' );
     $.ajax({
           type: "POST",
           url: "<?php echo base_url();?>+'Treatments_Controller/addImageData'",
                    data: {"pic_id=" + id + "&name=" + name + "&pic_x=" + mouseX + "&pic_y=" + mouseY + "&type=insert"},
                    success: function(data){
                        //viewtag( id );
                        $('#tagit').fadeOut();
                        alert(data);
                    }
                });

            });

我已经更改了一些代码,请检查这是否有用。

相关问题