js网格有一列单选按钮

js网格有一列单选按钮

本文介绍了EXT js网格有一列单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var grid = new Ext.grid.GridPanel({
列:[
{header:'Account Id',dataIndex:'accountId'},
{header:'Account NUmber',dataIndex:'accountNumber'}
]
})

现在我需要将帐户ID列显示为一列单选按钮。所以从网格用户可以选择一个帐户ID并提交。当用户重新加载页面时,应该预先选择该帐户ID。



我需要一些关于如何继续的帮助。我需要在帐户ID列上写一个渲染器吗?或者有一个更简单的方法。



编辑:我这样做:

  {header:'Account Id',dataIndex:'accountId',renderer:function(value){
return< input type ='radio'name ='primaryRadio'+(value? ='checked':)+>;
}},

将onclick事件或onchange事件添加到广播组?

解决方案

通过使用渲染器功能,您将Account Id列显示为单选按钮列。 / p>

关于这些的onclick事件,您可以在HTML标签中添加onclick属性:

  return< input onclick ='my_function()'type ='radio'name ='primaryRadio'+(value?checked ='checked':)+& ; 


I have an ext js grid like below:

var grid = new Ext.grid.GridPanel({
columns: [
{header: 'Account Id',dataIndex:'accountId' },
{header: 'Account NUmber',dataIndex:'accountNumber' }
]
})

Now I need to show Account Id column as a column of radio buttons. So from the grid user can select one Account Id and submit. When the user reloads the page, that account id should be preselected.

I need some help on how to proceed on this. Do I need to write a renderer on Account Id column? Or is there an easier way.

EDIT: I did like this:

{header: 'Account Id',dataIndex:'accountId',renderer: function(value) {
return "<input type='radio' name = 'primaryRadio' " + (value ? "checked='checked'" : "") + ">";
 }},

What is the syntax to add an onclick event or onchange event to the radio group?

解决方案

You did well on showing Account Id column as a column of radio buttons, by using a renderer function.

Regarding the onclick event for these, you may simply add the onclick attribute in the HTML tag:

return "<input onclick='my_function()' type='radio' name = 'primaryRadio' " + (value ? "checked='checked'" : "") + ">";

这篇关于EXT js网格有一列单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 01:35